mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
strconv: bug fix for "${239.5:0.0f}" (#13483)
This commit is contained in:
parent
6d2a88e31f
commit
9c24d09dc3
2 changed files with 88 additions and 1 deletions
|
@ -156,7 +156,7 @@ pub fn f64_to_str_lnd1(f f64, dec_digit int) string {
|
|||
|
||||
mut dot_res_sp := -1
|
||||
|
||||
// get sign and deciaml parts
|
||||
// get sign and decimal parts
|
||||
for c in s {
|
||||
if c == `-` {
|
||||
sgn = -1
|
||||
|
@ -263,6 +263,10 @@ pub fn f64_to_str_lnd1(f f64, dec_digit int) string {
|
|||
|
||||
// no more digits needed, stop here
|
||||
if dec_digit <= 0 {
|
||||
// C.printf(c'f: %f, i: %d, res.data: %p | dot_res_sp: %d | *(res.data): %s \n', f, i, res.data, dot_res_sp, res.data)
|
||||
if dot_res_sp < 0 {
|
||||
dot_res_sp = i + 1
|
||||
}
|
||||
tmp_res := tos(res.data, dot_res_sp).clone()
|
||||
res.free()
|
||||
return tmp_res
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue