From 3e23cf943e94837cb891f516b5de447e02340e31 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 30 Oct 2020 14:19:19 +0800 Subject: [PATCH] Add to_float from f32 to f64. --- src/packages/math_basic.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/packages/math_basic.rs b/src/packages/math_basic.rs index 67ae918e..c723d853 100644 --- a/src/packages/math_basic.rs +++ b/src/packages/math_basic.rs @@ -215,6 +215,10 @@ mod float_functions { Ok((x.trunc() as INT).into()) } } + #[rhai_fn(name = "to_float")] + pub fn f32_to_float(x: f32) -> FLOAT { + x as FLOAT + } #[rhai_fn(name = "to_int", return_raw)] pub fn f64_to_int(x: f64) -> Result> { if cfg!(not(feature = "unchecked")) && x > (MAX_INT as f64) {