1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

strconv: fix f64_to_str_lnd and f64_to_str_l after 6921d46

This commit is contained in:
Delyan Angelov 2020-08-27 14:21:57 +03:00
parent c01d17fcc4
commit 8f5cefb116
2 changed files with 5 additions and 5 deletions

View File

@ -128,7 +128,7 @@ pub fn f64_to_str_lnd(f f64, dec_digit int) string {
// allocate exp+32 chars for the return string
//mut res := []byte{len:exp+32,init:`0`}
mut res := [`0`].repeat(exp+32) // TODO: Slow!! is there other possibilities to allocate this?
mut res := []byte{len: exp+32, init: 0}
mut r_i := 0 // result string buffer index
//println("s:${sgn} b:${b[0]} es:${exp_sgn} exp:${exp}")
@ -182,7 +182,7 @@ pub fn f64_to_str_lnd(f f64, dec_digit int) string {
}
res[r_i] = 0
//println("result: [${tos(&res[0],r_i)}]")
return tos(&res[0],r_i)
return tos(res.data, r_i)
} else {
if dec_digit > 0 {
mut c := 0
@ -193,7 +193,7 @@ pub fn f64_to_str_lnd(f f64, dec_digit int) string {
}
res[r_i] = 0
}
return tos(&res[0],r_i)
return tos(res.data, r_i)
}
}

View File

@ -290,7 +290,7 @@ pub fn f64_to_str_l(f f64) string {
}
// allocate exp+32 chars for the return string
mut res := [`0`].repeat(exp+32) // TODO: Slow!! is there other possibilities to allocate this?
mut res := []byte{len: exp+32, init: 0}
mut r_i := 0 // result string buffer index
//println("s:${sgn} b:${b[0]} es:${exp_sgn} exp:${exp}")
@ -335,5 +335,5 @@ pub fn f64_to_str_l(f f64) string {
}
}
res[r_i] = 0
return tos(&res[0],r_i)
return tos(res.data,r_i)
}