diff --git a/vlib/strconv/atof.v b/vlib/strconv/atof.v index 4a60d9af22..5df6bc5eac 100644 --- a/vlib/strconv/atof.v +++ b/vlib/strconv/atof.v @@ -522,6 +522,7 @@ pub fn atof64(s string) f64 { res_parsing,pn = parser(s + ' ') // TODO: need an extra char for now // println(pn) + unsafe { match res_parsing { parser_ok { res.u = converter(mut pn) @@ -539,6 +540,8 @@ pub fn atof64(s string) f64 { res.u = double_minus_infinity } else { - }} + } + } return res.f + } } diff --git a/vlib/strconv/atofq.v b/vlib/strconv/atofq.v index e322294005..70e84c0359 100644 --- a/vlib/strconv/atofq.v +++ b/vlib/strconv/atofq.v @@ -37,6 +37,7 @@ pub fn atof_quick(s string) f64 { i++ } } + unsafe { // infinite if s[i] == `i` && i + 2 < s.len && s[i + 1] == `n` && s[i + 2] == `f` { if sign > 0.0 { @@ -133,6 +134,7 @@ pub fn atof_quick(s string) f64 { } f.f = f.f * sign return f.f + } } const ( diff --git a/vlib/strconv/f32_str.v b/vlib/strconv/f32_str.v index ae26e94bac..b6409cbf10 100644 --- a/vlib/strconv/f32_str.v +++ b/vlib/strconv/f32_str.v @@ -321,8 +321,8 @@ pub fn f32_to_decimal(mant u32, exp u32) Dec32 { // f32_to_str return a string in scientific notation with max n_digit after the dot pub fn f32_to_str(f f32, n_digit int) string { mut u1 := Uf32{} - u1.f = f - u := u1.u + unsafe { u1.f = f } + u := unsafe {u1.u} neg := (u>>(mantbits32+expbits32)) != 0 mant := u & ((u32(1)<>(mantbits32+expbits32)) != 0 mant := u & ((u32(1)<>(mantbits64+expbits64)) != 0 mant := u & ((u64(1)<>(mantbits64+expbits64)) != 0 mant := u & ((u64(1)<