>> +00123.4
== 123.4
Float! datatype
1. Abstract
A float!
value represents a 64bit positive or negative number that contains a decimal point.
Float values span a range from 1.7E+308
to +1.7E+308
and return #INF
on overflow.
Dividing by zero returns 1.#NaN
.
Float!
is a member of the following typesets: immediate!
, number!
, scalar!
2. Creation
Float values can be created using literal syntax, or at runtime by using a make
constructor or to
conversion.
3. Literal syntax
Zero or more digits, followed by a dot .
, followed by one or more digits.
A comma can be used in place of the dot for the decimal point.
123,4
Note

A formed value will normalize a decimal comma to a decimal point as the decimal mark. 
+
or 
immediately before the first digit indicates the positive or negative sign of the float!
.
+123.4
123.4
Leading zeros are ignored.
Single quote '
is used as a place value separator for large values, and can appear anywhere after the first digit.
>> 60'000'12'3.4
== 60000123.4
A single quote '
immediately before or after the decimal point will raise an error.
>> 60'000'123'.4
*** Syntax Error: invalid integer! at "60'000'123'.4"
*** Where: do
*** Stack: load
>> 60'000'123.'4
*** Syntax Error: invalid integer! at "60'000'123.'4"
*** Where: do
*** Stack: load
3.1. Runtime creation

Literal syntax
>> 100.1
== 100.1

make
>> make float! 1
== 1.0

to
>> to float! 42
== 42.0
Note

When supplying a value of anylist to make or to , the anylist value must contain two numbers. The result will be the first number multiplied with the value of 10 to the power of the truncated second number. firstnumber * (power 10 secondnumber)


block
>> make float! [2 3]
== 2000.0
>> to float! [4 2]
== 400.0

paren
>> make float! quote (2 3)
== 2000.0
>> to float! quote (4 2)
== 400.0

hash
>> list: make hash! [2 3]
== make hash! [2 3]
>> to float! list
== 2000.0
>> list: make hash! [4 2]
== make hash! [4 2]
>> to float! list
== 400.0
4. Comparisons
All comparators can be applied on float!
: =, ==, <>, >, <, >=, <=, =?
. In addition, min
, and max
are also supported.
5. Conversion
A float value can be converted at runtime to anylist!
, binary!
, char!
, integer!
, string!
, or time!
by using a to
conversion.
An anylist!
value must contain two numbers. The result will be the first number multiplied with the value of 10 to the power of the truncated second number. firstnumber * (power 10 secondnumber)
>> to float! [4 2] ; 4 * (power 10 2)
== 400.0

to binary!
interprets the first 8 bytes as a floating point number. If there are fewer than 8 bytes, #{00} bytes are prepended.
>> to binary! 42.3
== #{4045266666666666}
Note

The digits after the decimal point will be discarded when converting a float to char! or integer! . No rounding will take place.

>> to char! 123.4
== #"{"
>> to char! 123 ; equivalent, since .4 is discarded
== #"{"
>> to integer! 123.4
== 123

to string!
>> to string! 123.4
== "123.4"

to time!
returns the number of seconds and milliseconds.
>> to time! 42.7
== 0:00:42.7
If float!
and integer!
are combined in an expression, the result will be a float!
value.
>> 123.4 * 42
== 5182.8
6. Testing values
Use float?
to check if a value is of the float!
datatype.
>> float? 123.4
== true
Use type?
to return the datatype of a given value.
>> type? 123.4
== float!
7. Predefined words
7.1. Functions
acos
, asin
, atan
, atan2
, cos
, distance?
, float?
, sin
, sqrt
, tan
, tofloat
7.2. Natives
arccosine
, arcsine
, arctangent
, arctangent2
, aspair
, cosine
, exp
, log10
, log2
, loge
, sine
, squareroot
, tangent
7.3. Operators
**