mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
float: make default string representations for floats become alike
This commit is contained in:
@@ -21,8 +21,17 @@ fn test_float_lit_call_method() {
|
||||
x4 := .003e2.str()
|
||||
assert x4 == '0.3'
|
||||
x5 := 2.e-3.str()
|
||||
assert x5 == '2.e-03'
|
||||
assert x5 == '0.002'
|
||||
x6 := 5.0.str()
|
||||
assert x6 == '5.'
|
||||
// x7 := 5..str() Syntax `5.` is allowed, but do not call method on it (`5..str()` is parsed as a range). Use `5.0.str()` instead.
|
||||
x8 := 7.345e-7.str()
|
||||
assert x8 == '7.345e-07'
|
||||
x9 := 5.725e6.str()
|
||||
assert x9 == '5.725e+06'
|
||||
|
||||
a := f32(12.3).str()
|
||||
assert a[0..4] == '12.3' // there is still trailing garbage
|
||||
assert f32(7.345e-7).str() == '7.345e-07'
|
||||
assert f32(5.725e6).str() == '5.725e+06'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user