mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Support Num.toStr for f32, f64
This commit is contained in:
parent
6ac9c37e06
commit
b7c312d449
7 changed files with 79 additions and 14 deletions
|
@ -5496,7 +5496,14 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
// Str.fromFloat : Float * -> Str
|
||||
debug_assert_eq!(args.len(), 1);
|
||||
|
||||
str_from_float(env, scope, args[0])
|
||||
let (float, float_layout) = load_symbol_and_layout(scope, &args[0]);
|
||||
|
||||
let float_width = match float_layout {
|
||||
Layout::Builtin(Builtin::Float(float_width)) => *float_width,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
str_from_float(env, float, float_width)
|
||||
}
|
||||
StrFromUtf8Range => {
|
||||
debug_assert_eq!(args.len(), 3);
|
||||
|
@ -5815,8 +5822,8 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
str_from_int(env, int, *int_width)
|
||||
}
|
||||
Layout::Builtin(Builtin::Float(_float_width)) => {
|
||||
str_from_float(env, scope, args[0])
|
||||
Layout::Builtin(Builtin::Float(float_width)) => {
|
||||
str_from_float(env, num, *float_width)
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue