After a long time having only partial floating point support in Red/System, it comes now to Red with a broader support, thanks to the terrific work from Qtxie and Oldes, who managed to push Red further while I was busy moving from Europe to China (though, this might be the topic for another blog entry, as requested by many of you).

The new

datatype implements IEEE-754 64-bit floating point format. It is available with most of the usual math functions support:**float!**

- infix operators: +, -, *, /, **.
- prefix base functions:
`add, substract, multiply, divide, power.`

- trigonometric functions:
**cosine, sine, tangent, arcsine, arccosine, arctangent.** - other math functions:
**log-2, log-10, log-e, exp, square-root, round**

Note that these trigonometric functions are taking arguments in **degrees**, a ** /radians** refinement is provided for input values in

((sine/radians b) * (cosine/radians c)) + ((cosine/radians b) * (sine/radians c))

Some radians-oriented shortcuts to these functions are also provided for convenience:** cos, sin, tan, arcsin, arccos, arctan**. So the above expression becomes:

((sin b) * (cos c)) + ((cos b) * (sin c))

Here are some code examples from Red console:

red>> 1.23456 == 1.23456 red>> 1e10 == 10000000000.0 red>> 1.23 * 2 == 2.46 red>> 1.23 * 2.0 == 2.46 red>> to integer! 1.23 * 2.0 == 2 red>> cos pi == -1.0 red>> sin pi == 0.0 red>> cos pi / 2 == 0.0 red>> cos pi / 3 == 0.5 red>> cosine/radians pi / 3 == 0.5 red>> cosine 60 == 0.5 red>> .1 + .2 + .3 == 0.6 red>> .1 + .2 + .3 = .6 == true red>> .1 + .2 + .3 - .6 == 1.110223024625157e-16 red>> float' load "0.1" == true red>> to float! 1 == 1.0 red>> 1 = to integer! to float! 1 == true

As you can see, Red tries to give you meaningful outputs even when the result is not exact, but this approach has its limits too. Qtxie has ported partially dtoa() functions to Red/System, however, the overhead of the additional code (20-40KB once compiled) is quite costly given how tiny is currently our runtime library (~350KB). So, for now, that implementation has been provided as an optional library for Red/System, and will be modularized for Red, once modules will be supported.

You might know that standard floating point format supports a few extra special values that are meant to make some calculation possible in edge cases. Those are also supported natively by Red, with the following literal formats:

Not a Number (NaN) : 1.#NaN Positive Infinity (+INF) : +1.#INF (or just 1.#INF) Negative Infinity (-INF) : -1.#INF Positive Zero : +0.0 (or just 0.0) Negative Zero : -0.0

These values are mostly intended for scientific calculations, you do not have to worry about them. They can be produced as results of some math operations on floats, but by default, an error will be thrown instead.

In case, you need to operate with maximum precision, and have all the special float values as results instead of errors, a couple of flags are available for that through the ** system **special access. The syntax is:

system/float-options [spec] [spec]: block of flags (word! | set-word!) with values (logic! | word!)

Valid flags are:

: enables pretty printing of float numbers when very close to an integer value (default: true)`pretty'`

: enables math operations on float special values (default: false)`full'`

Examples:

So far, Red supported only the armel ABI for ARM backends. Since this release, we fully support now armhf ABI too, through a specific compilation option that can be found in the new **RPi** compilation target (intended mainly for default OS on RaspberryPi). The main difference between these ABI is the way float values are passed as arguments to functions, armel requires passing them on stack, while armhf requires passing them through FPU registers.

datatype preliminary support: all actions are working, but no path access support yet.**url!**- New actions:
(*),`reverse, random, swap, take, to`

`trim`

- New natives:
**same’, NaN’** - New mezzanines:
**float’, routine’** - Red/System FPU direct access through system/fpu/* options.
- Help command now displays full help on routines too.
- Many bug fixes and a few wishes granted.

(*) ** to **is currently limited to integer/float/string conversions only.

After the digression in the floating point lands, we go back to our main roadmap, so in the next releases, expect (in no particular order):

- GUI support for Android / Windows platforms
- Improved toolchain for Android APK generation
- Object compilation support
- New console engine
- Error! datatype and exceptions handling
- Typeset! and other new datatypes
- Redbin format specification and implementation for the compiler
- Improved compiler performance

Thanks for your patience and support during these last months, we are now back to our cruise development speed, so expect faster changes until the end of the year.

- July, 2016 (2 posts)
- June, 2016 (1 post)
- March, 2016 (1 post)
- December, 2015 (1 post)
- June, 2015 (1 post)
- April, 2015 (2 posts)
- March, 2015 (1 post)
- January, 2015 (1 post)
- December, 2014 (2 posts)
- August, 2014 (1 post)
- April, 2014 (1 post)
- February, 2014 (1 post)
- January, 2014 (1 post)
- November, 2013 (1 post)
- September, 2013 (1 post)
- August, 2013 (1 post)
- March, 2013 (1 post)
- January, 2013 (1 post)
- December, 2012 (1 post)
- October, 2012 (1 post)
- September, 2012 (2 posts)
- August, 2012 (1 post)
- March, 2012 (2 posts)
- February, 2012 (1 post)
- December, 2011 (1 post)
- September, 2011 (2 posts)
- August, 2011 (1 post)
- July, 2011 (2 posts)
- May, 2011 (3 posts)
- April, 2011 (1 post)
- March, 2011 (4 posts)
- February, 2011 (1 post)

- 2d (1)
- alias (1)
- alpha (1)
- android (3)
- announce (6)
- arm (4)
- armhf (1)
- arrays (1)
- beta (1)
- binary-form (1)
- bitset (1)
- blog (1)
- booleans (1)
- bridge (2)
- bugfixes (3)
- callback (1)
- casing (1)
- china (2)
- codecs (1)
- collation (1)
- community (1)
- compilation (4)
- compiler (2)
- conference (2)
- console (6)
- context (2)
- contribution (1)
- csdn (1)
- debian (1)
- demos (3)
- dialect (1)
- dll (1)
- donations (1)
- draw (1)
- dsl (1)
- dynamic-calls (1)
- elf (1)
- encap (1)
- enum (1)
- exceptions (2)
- features (1)
- floating-point (2)
- floats (2)
- fpu (3)
- freebsd (1)
- functions (1)
- gtk (1)
- gui (5)
- hash (1)
- i-o (1)
- ia-32 (1)
- ieee-754 (1)
- implementation (1)
- interpreter (1)
- ios (1)
- iw (1)
- java (2)
- jni (1)
- lexer (1)
- libc (1)
- linker (1)
- linux (2)
- literal-arrays (1)
- livecoding (1)
- load (1)
- loader (1)
- macosx (1)
- map (1)
- math (1)
- meeting (1)
- namespaces (1)
- native (1)
- objective-c (1)
- objects (3)
- ownership (1)
- pair (1)
- parse (3)
- path-notation (1)
- paths (1)
- percent (1)
- pointers (1)
- port (1)
- presentation (2)
- qemu (1)
- questions (1)
- raspberrypi (2)
- react (1)
- reactive (4)
- red (2)
- red-system (3)
- redbin (1)
- release (11)
- repl (2)
- routine (1)
- runtime-errors (2)
- sets (1)
- sfd (1)
- shared-libraries (2)
- sorting (1)
- sources (1)
- specs (2)
- stack (1)
- startups (1)
- stats (1)
- strings (1)
- sum-up (1)
- svg (1)
- tests (3)
- time (1)
- tuple (1)
- tutorial (1)
- type-checking (1)
- typeset (1)
- unicode (4)
- update (1)
- user-group (1)
- vector (2)
- vfp (1)
- vid (1)
- view (2)
- widgets (1)
- x87 (1)