mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
strconv: change atof64 to return an error, if the parsed value is not a valid number (#13424)
This commit is contained in:
@@ -511,12 +511,12 @@ pub fn (s string) i16() i16 {
|
||||
|
||||
// f32 returns the value of the string as f32 `'1.0'.f32() == f32(1)`.
|
||||
pub fn (s string) f32() f32 {
|
||||
return f32(strconv.atof64(s))
|
||||
return f32(strconv.atof64(s) or { 0 })
|
||||
}
|
||||
|
||||
// f64 returns the value of the string as f64 `'1.0'.f64() == f64(1)`.
|
||||
pub fn (s string) f64() f64 {
|
||||
return strconv.atof64(s)
|
||||
return strconv.atof64(s) or { 0 }
|
||||
}
|
||||
|
||||
// u8 returns the value of the string as u8 `'1'.u8() == u8(1)`.
|
||||
|
||||
Reference in New Issue
Block a user