Yichus/Num/Float64
Builtin package (resource numeric.bosatsu).
This is the complete package source used by this build. The export
list names its public API; definitions below give the types and behavior.
New to the API? Start with Make a data app or Build an API, then use this page to look up a definition.
package Yichus/Num/Float64 from Bosatsu/Predef import Int, Bool export ( Float64, Comparison(), `+.`, `-.`, `*.`, `/.`, addf, subf, mulf, divf, add_Double, sub_Double, mul_Double, div_Double, int_to_Float64, float64_to_Int, from_Int, to_Int, cmp_Float64, eq_Float64, cmp_Double, eq_Double, neg_Float64, abs_Float64, minf, maxf, powf, lnf ) # Every function gives the same answer on the JVM interpreter (yichus eval) # and in generated JavaScript: IEEE-754 binary64 arithmetic, with the # choices below where JavaScript's operators and Java's differ. external type Float64 # Comparison result type enum Comparison: LT, EQ, GT external def `+.`(a: Float64, b: Float64) -> Float64 external def `-.`(a: Float64, b: Float64) -> Float64 external def `*.`(a: Float64, b: Float64) -> Float64 external def `/.`(a: Float64, b: Float64) -> Float64 external def addf(a: Float64, b: Float64) -> Float64 external def subf(a: Float64, b: Float64) -> Float64 external def mulf(a: Float64, b: Float64) -> Float64 external def divf(a: Float64, b: Float64) -> Float64 external def add_Double(a: Float64, b: Float64) -> Float64 external def sub_Double(a: Float64, b: Float64) -> Float64 external def mul_Double(a: Float64, b: Float64) -> Float64 external def div_Double(a: Float64, b: Float64) -> Float64 # Conversion between Int and Float64. int_to_Float64 rounds to nearest and # never gives -0.0. float64_to_Int truncates toward zero and saturates at # the JS backend's exact Int range, -9007199254740991 to 9007199254740991; # a NaN gives 0. from_Int and to_Int are the same two functions. external def int_to_Float64(i: Int) -> Float64 external def float64_to_Int(d: Float64) -> Int external def from_Int(i: Int) -> Float64 external def to_Int(d: Float64) -> Int # Comparison is Java's Double.compare, a total order: -0.0 is below 0.0, # a NaN equals every NaN and is above every other value. eq is its EQ. external def cmp_Float64(a: Float64, b: Float64) -> Comparison external def eq_Float64(a: Float64, b: Float64) -> Bool external def cmp_Double(a: Float64, b: Float64) -> Comparison external def eq_Double(a: Float64, b: Float64) -> Bool # Unary operations external def neg_Float64(a: Float64) -> Float64 external def abs_Float64(a: Float64) -> Float64 # minf and maxf: a NaN in gives NaN; -0.0 is below 0.0. powf is fdlibm's # pow (Java's StrictMath.pow), the same bits on every engine. external def minf(a: Float64, b: Float64) -> Float64 external def maxf(a: Float64, b: Float64) -> Float64 external def powf(base: Float64, exp: Float64) -> Float64 # Natural logarithm, fdlibm (Java's StrictMath.log) on every engine. # Zero gives negative infinity; negative arguments give NaN. external def lnf(x: Float64) -> Float64