This module provides the definitions and functionalities of WideFloat type.
Record type that represents inner content of WideFloat.
Creates a WideFloat value from specified exponent and significand. The value create { base2toThe1024exponent = a, significand = b} corresponds to b * 2^(1024a).
create
{ base2toThe1024exponent = 0
, significand = 2 ^ 513
}
== create
{ base2toThe1024exponent = 1
, significand = 2 ^ -511
} -->TrueCreates a WideFloat value from specified float
fromFloat 1
== one --> 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 = 0
, significand = 2^50
}
)
|> differenceFrom
( create
{ base2toThe1024exponent = 0
, significand = 2^50
}
)
|> 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 = 2^(-511)
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 99
, significand = 2^511
}
add w1 w2 --> create { base2toThe1024exponent = 100, significand = 1.25 * 2^(-511) }Subtracts WideFloat value given as the first parameter from the second. Reads naturally when used with pipe(|>).
w1 : WideFloat
w1 =
create
{ base2toThe1024exponent = 1
, significand = 2^(-511)
}
w2 : WideFloat
w2 =
create
{ base2toThe1024exponent = 0
, significand = 2^511
}
w1 |> differenceFrom w2 --> create { base2toThe1024exponent = 1, significand = 1.5 * 2^(-512) }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 = 300, significand = 2.625 }multiplies a Float value on a WideFloat value.
w : WideFloat
w =
create
{ base2toThe1024exponent = 0
, significand = 2^(500)
}
multiplyFloat (2^20) w --> create { base2toThe1024exponent = 1, significand = 256 * 2 ^(-512) }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 = 2^511
}
p : Float
p =
proportionOf w1 w2
p <= 0.8001 --> True
p >= 0.7999 --> TrueReturns a record representing the inner content of WideFloat.
Inverse function of create (when significand is specified properly).
content : Content
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 42 exponent bits and 52 significand bits.