mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Switch from floats to usize
This commit is contained in:
parent
d976f2fc93
commit
c8f6762deb
4 changed files with 8 additions and 8 deletions
|
@ -22,12 +22,12 @@ pub fn asin(num: f64) callconv(.C) f64 {
|
||||||
return @call(.{ .modifier = always_inline }, math.asin, .{num});
|
return @call(.{ .modifier = always_inline }, math.asin, .{num});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: Obviously, this should not be an alias for arcsin(x);
|
/// TODO: Obviously, this should not be an alias for x + 1.
|
||||||
/// fix me!
|
/// fix me!
|
||||||
pub fn bytesToU16C(num: f64) callconv(.C) f64 {
|
pub fn bytesToU16C(num: usize) callconv(.C) usize {
|
||||||
return @call(.{ .modifier = always_inline }, bytesToU16, .{num});
|
return @call(.{ .modifier = always_inline }, bytesToU16, .{num});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bytesToU16(num: f64) f64 {
|
fn bytesToU16(num: usize) usize {
|
||||||
return num + 1;
|
return num + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,8 +505,8 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
||||||
// bytesToU16 : Float a -> Float a
|
// bytesToU16 : Float a -> Float a
|
||||||
add_top_level_function_type!(
|
add_top_level_function_type!(
|
||||||
Symbol::NUM_BYTES_TO_U16,
|
Symbol::NUM_BYTES_TO_U16,
|
||||||
vec![float_type(flex(TVAR1))],
|
vec![nat_type()],
|
||||||
Box::new(float_type(flex(TVAR1))),
|
Box::new(nat_type()),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Bool module
|
// Bool module
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ fn num_asin(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: This is obviously wrong! Fix me!
|
/// TODO: This is obviously wrong! Fix me!
|
||||||
/// Num.bytesToU16 : Float -> Float
|
/// Num.bytesToU16 : Nat -> Nat
|
||||||
fn num_bytes_to_u16(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
fn num_bytes_to_u16(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||||
let arg_float_var = var_store.fresh();
|
let arg_float_var = var_store.fresh();
|
||||||
let ret_float_var = var_store.fresh();
|
let ret_float_var = var_store.fresh();
|
||||||
|
|
|
@ -1623,11 +1623,11 @@ mod gen_num {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn num_bytes_to_u16_ascii() {
|
fn num_bytes_to_u16_ascii() {
|
||||||
assert_evals_to!("Num.bytesToU16 1", 2.0, f64);
|
assert_evals_to!("Num.bytesToU16 1", 2, usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn num_bytes_to_u16_ascii_2() {
|
fn num_bytes_to_u16_ascii_2() {
|
||||||
assert_evals_to!("Num.bytesToU16 0", 1.0, f64);
|
assert_evals_to!("Num.bytesToU16 0", 1, usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue