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

strconv: minor cleanup in f64_to_str_lnd1() (#13804)

This commit is contained in:
yuyi 2022-03-23 02:15:59 +08:00 committed by GitHub
parent 0337882240
commit e3dca82f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,31 +158,38 @@ pub fn f64_to_str_lnd1(f f64, dec_digit int) string {
// get sign and decimal parts // get sign and decimal parts
for c in s { for c in s {
if c == `-` { match c {
`-` {
sgn = -1 sgn = -1
i++ i++
} else if c == `+` { }
`+` {
sgn = 1 sgn = 1
i++ i++
} else if c >= `0` && c <= `9` { }
`0`...`9` {
b[i1] = c b[i1] = c
i1++ i1++
i++ i++
} else if c == `.` { }
`.` {
if sgn > 0 { if sgn > 0 {
d_pos = i d_pos = i
} else { } else {
d_pos = i - 1 d_pos = i - 1
} }
i++ i++
} else if c == `e` { }
`e` {
i++ i++
break break
} else { }
else {
s.free() s.free()
return '[Float conversion error!!]' return '[Float conversion error!!]'
} }
} }
}
b[i1] = 0 b[i1] = 0
// get exponent // get exponent