The definitions and functionalities of WideFloat type (which is explained in README.md).
Record type that represents inner content of WideFloat.
Creates a WideFloat value from specified exponent and significand. If the absolute value of given significand is greater 2 or less than 1, n is added to the exponent and 2^(-n) is multiplied to the significand where n denote floor (logBase 2 (abs significand))
create { base2toThe1024exponent = 0, significand = 10 }
== create { base2toThe1024exponent = 3, significand = 1.25 }
--> TrueCreates a WideFloat value from specified float
fromFloat (1024.0 * 1024.0 * 1024.0 * 1024.0)
== create { base2toThe1024exponent = 40, significand = 1 }
--> TrueReturns True if the parameter is recognized as zero in floating point precision.
fromFloat 1
|> add
( create
{ base2toThe1024exponent = 100
, significand = 1
}
)
|> differenceFrom
( create
{ base2toThe1024exponent = 100
, significand = 1
}
)
|> isZero --> True
fromFloat 1
|> add
( create
{ base2toThe1024exponent = 50
, significand = 1
}
)
|> differenceFrom
( create
{ base2toThe1024exponent = 50
, significand = 1
}
)
|> isZero --> FalseReturns True if the second parameter is larger than first one. Reads naturally when used with pipe operator(|>).
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 1000
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 999
, significand = 1.999
}
w1 |> isLargerThan w2 --> True
w2 |> isLargerThan w1 --> FalseReturns True if the second parameter is smaller than first one. Reads naturally when used with pipe operator(|>).
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 1000
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 999
, significand = 1.999
}
w1 |> isSmallerThan w2 --> False
w2 |> isSmallerThan w1 --> TrueReturns True if the value of first parameter is the same as the second parameter.
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 1000
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 50
, significand = 1
}
|> add
(create
{ base2toThe1024exponent = 0
, significand = 1
}
)
w1 |> isEqualTo w1 --> True
w1 |> isEqualTo w2 --> Falseadds two WideFloats.
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 100
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 99
, significand = 1
}
add w1 w2 --> create { base2toThe1024exponent = 100, significand = 1.5 }Subtracts WideFloat value given as the first parameter from the second. Reads naturally when used with pipe(|>).
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 100
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 99
, significand = 1.75
}
w1 |> differenceFrom w2 --> create { base2toThe1024exponent = 97, significand = 1.0 }Multiplies two WideFloats.
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 100
, significand = 1.5
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 200
, significand = 1.75
}
multiply w1 w2 --> create { base2toThe1024exponent = 301, significand = 1.3125 }multiplies a Float value on a WideFloat value.
w : WideFloat
w =
create
{ base2toThe1024exponent = 100
, significand = 1
}
multiplyFloat 3 w --> create { base2toThe1024exponent = 101, significand = 1.5 }Returns ratio between to WideFloats. Reads naturally when used with pipe(|>).
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 100
, significand = 1
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 99
, significand = 1.6
}
w1 |> dividedBy w2
|> differenceFrom ( create { base2toThe1024exponent = 0, significand = 1.25})
|> isSmallerThan ( create { base2toThe1024exponent = -30, significand = 1})--> TrueReturns proportion of the first parameter in the sum of first and second parameters.
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 100
, significand = 2 ^ (-511)
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 99
, significand = 1
}
proportionOf w1 w2 == 2.0 / 3.0 --> TrueReturns a record representing the inner content of WideFloat.
Inverse function of create (when significand is specified properly).
content : { base2toThe1024exponent : Int, significand : Float}
content =
{ base2toThe1024exponent = 1000, significand = 1.234 }
getInternal (create content)
== content --> TrueReturns a String value representing the base 10 expression of a WideFloat. You can specify how many digits is shown after decimal point as the first parameter. The result may be a little less precise than other calcurations implemented in this module.
create
{ base2toThe1024exponent = 1
, significand = 1
}
|> toString 3 --> "1.798e308"If you want some other formats, you can make your original toString function using getInternal.
Opaque type that represents floating point number with 32 exponent bits and 52 significand bits.