mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: fix f32.str() (#16391)
This commit is contained in:
parent
c1a44efc78
commit
c9ce5f89c7
@ -85,10 +85,10 @@ pub fn (x f32) str() string {
|
|||||||
f: x
|
f: x
|
||||||
}
|
}
|
||||||
if f.u == strconv.single_minus_zero {
|
if f.u == strconv.single_minus_zero {
|
||||||
return '-0.'
|
return '-0.0'
|
||||||
}
|
}
|
||||||
if f.u == strconv.single_plus_zero {
|
if f.u == strconv.single_plus_zero {
|
||||||
return '0.'
|
return '0.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abs_x := f32_abs(x)
|
abs_x := f32_abs(x)
|
||||||
|
@ -228,3 +228,12 @@ fn test_float_point_formatting_rounding() {
|
|||||||
assert '${-239.55555555555:0.1f}' == '-239.6'
|
assert '${-239.55555555555:0.1f}' == '-239.6'
|
||||||
assert '${-239.55555555555:0.0f}' == '-240'
|
assert '${-239.55555555555:0.0f}' == '-240'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_float_zero_str() {
|
||||||
|
f1 := f32(0.0)
|
||||||
|
f2 := 0.0
|
||||||
|
assert f1.str() == '0.0'
|
||||||
|
assert '$f1' == '0.0'
|
||||||
|
assert f2.str() == '0.0'
|
||||||
|
assert '$f2' == '0.0'
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user