| NAN -> float | A not-a-number representation. |
|---|---|
| INFINITY -> float | The infinity representation. |
| MAX-FINITE -> float | The maximum finite float. |
| MIN-POSITIVE -> float | The minimum positive float. |
| parse data/Data -> float | Parses the data to a float. |
| parse data/Data [--on-error] -> float | |
| parse data/Data [--if-error] -> float | |
| parse data/Data from/int to/int= -> float | |
| from-bits raw/int -> float | |
| from-bits32 raw/int -> float |
float.from-bits (float.NAN.bits + 1)
float.NAN == float.from-bits (float.NAN.bits + 1) // => false
float.parse "2" // => 2.0
float.parse "2.0" // => 2.0
float.parse "2.1" // => 2.1000000000000000888
float.parse "007" // => 7.0
float.parse "anno 2017" // Error.
< this comparison handles 0.0 and -0.0, such that 0.0.compare-to -0.0 returns 1.
2.compare-to 1 // => 1
1.compare-to 1 // => 0
1.compare-to 2 // => -1
(-0.0).compare-to 0.0 // => -1
2.compare-to float.NAN // => -1
float.INFINITY.compare-to 3 // => 1
float.INFINITY.compare-to float.INFINITY // => 0
3.compare-to float.INFINITY // => -1
MyTime implements a lexicographical ordering of seconds and nanoseconds using compare-to other [--if-equal] to move on to nanoseconds when the seconds component is equal.
class MyTime:
seconds/int
nanoseconds/int
constructor .seconds .nanoseconds:
compare-to other/MyTime -> int:
return seconds.compare-to other.seconds --if-equal=:
nanoseconds.compare-to other.nanoseconds
2.0.is-finite // => true
(-9001.0).is-finite // => true
2.sqrt.is-finite // => true
float.MAX-FINITE.is-finite // => true
float.MIN_POSITIVE.is-finite // => true
float.NAN.is-finite // => false
(-1).sqrt.is-finite // => false
float.INFINITY.is-finite // => false
float.NAN.is-nan // => true
(-1).sqrt.is-nan // => true
(float.from-bits (float.NAN.bits + 1)).is-nan // => true
2.0.is-nan // => false
2.sqrt.is-nan // => false
float.INFINITY.is-nan // => false
float.MAX-FINITE.is-nan // => false
float.MIN_POSITIVE.is-nan // => false
3.1.round // => 3
3.4.round // => 3
3.5.round // => 4
3.9.round // => 4
(-5.1).round // => -5
(-5.4).round // => -5
(-5.5).round // => -6
(-5.9).round // => -6
(-0.0).round // => 0
2.sqrt.round // => 1
2.to-float // => 2.0
2.1.to-float // => 2.1
9223372036854775807.to-float // => 9223372036854775808.0