mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-09-11 20:47:25 +03:00
float -> u48 conversion
This commit is contained in:
parent
8808ca6534
commit
a491c3a8cc
24
book/Float/to_U48.kind2
Normal file
24
book/Float/to_U48.kind2
Normal file
@ -0,0 +1,24 @@
|
||||
/// Constructs a U48 from a Float. It truncates the float to the next integer.
|
||||
///
|
||||
/// Examples:
|
||||
/// - 1.25 (Float/new 125 2) -> 1 : U48
|
||||
/// - 1000.0 (Float/new 1 3) -> 1000 : U48
|
||||
/// - 0.75 (Float/new 75 2) -> 0 : U48
|
||||
///
|
||||
/// # Input
|
||||
///
|
||||
/// * `a` - The Float number.
|
||||
///
|
||||
/// # Output
|
||||
///
|
||||
/// The U48 representation of that number, truncated.
|
||||
|
||||
use Float/{new}
|
||||
|
||||
to_U48
|
||||
- a: Float
|
||||
: U48
|
||||
|
||||
match a {
|
||||
new: (Float/to_U48/go a.mantissa a.exponent)
|
||||
}
|
Loading…
Reference in New Issue
Block a user