mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
implement missing string to int type methods (#1210)
* implement missing string to int methods * make number base auto detected
This commit is contained in:
parent
7dc7502fe2
commit
8cd1f962d3
@ -133,6 +133,10 @@ pub fn (s string) int() int {
|
||||
return C.atoi(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) i32() i32 {
|
||||
return C.atol(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) i64() i64 {
|
||||
return C.atoll(s.str)
|
||||
}
|
||||
@ -141,6 +145,18 @@ pub fn (s string) f32() f32 {
|
||||
return C.atof(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) f64() f64 {
|
||||
return C.atof(s.str)
|
||||
}
|
||||
|
||||
pub fn (s string) u32() u32 {
|
||||
return C.strtoul(s.str, 0, 0)
|
||||
}
|
||||
|
||||
pub fn (s string) u64() u64 {
|
||||
return C.strtoull(s.str, 0, 0)
|
||||
}
|
||||
|
||||
// ==
|
||||
fn (s string) eq(a string) bool {
|
||||
if isnil(s.str) {
|
||||
|
Loading…
Reference in New Issue
Block a user