mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin,strconv: append ".0", to float string representations, to ensure clarity (#16079)
This commit is contained in:
@ -19,10 +19,10 @@ pub fn (x f64) str() string {
|
||||
f: x
|
||||
}
|
||||
if f.u == strconv.double_minus_zero {
|
||||
return '-0'
|
||||
return '-0.0'
|
||||
}
|
||||
if f.u == strconv.double_plus_zero {
|
||||
return '0'
|
||||
return '0.0'
|
||||
}
|
||||
}
|
||||
abs_x := f64_abs(x)
|
||||
@ -37,11 +37,11 @@ pub fn (x f64) str() string {
|
||||
[inline]
|
||||
pub fn (x f64) strg() string {
|
||||
if x == 0 {
|
||||
return '0'
|
||||
return '0.0'
|
||||
}
|
||||
abs_x := f64_abs(x)
|
||||
if abs_x >= 0.0001 && abs_x < 1.0e6 {
|
||||
return strconv.f64_to_str_l_no_dot(x)
|
||||
return strconv.f64_to_str_l_with_dot(x)
|
||||
} else {
|
||||
return strconv.ftoa_64(x)
|
||||
}
|
||||
@ -85,10 +85,10 @@ pub fn (x f32) str() string {
|
||||
f: x
|
||||
}
|
||||
if f.u == strconv.single_minus_zero {
|
||||
return '-0'
|
||||
return '-0.'
|
||||
}
|
||||
if f.u == strconv.single_plus_zero {
|
||||
return '0'
|
||||
return '0.'
|
||||
}
|
||||
}
|
||||
abs_x := f32_abs(x)
|
||||
@ -103,11 +103,11 @@ pub fn (x f32) str() string {
|
||||
[inline]
|
||||
pub fn (x f32) strg() string {
|
||||
if x == 0 {
|
||||
return '0'
|
||||
return '0.0'
|
||||
}
|
||||
abs_x := f32_abs(x)
|
||||
if abs_x >= 0.0001 && abs_x < 1.0e6 {
|
||||
return strconv.f32_to_str_l_no_dot(x)
|
||||
return strconv.f32_to_str_l_with_dot(x)
|
||||
} else {
|
||||
return strconv.ftoa_32(x)
|
||||
}
|
||||
|
Reference in New Issue
Block a user