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

fix hexadecimal constants + freestanding fixes

This commit is contained in:
bogen85
2019-11-25 21:12:37 -06:00
committed by Alexander Medvednikov
parent 92f920b2b8
commit 5c217b9e61
7 changed files with 175 additions and 54 deletions

View File

@@ -185,31 +185,11 @@ pub fn (s string) replace(rep, with string) string {
return tos(b, new_len)
}
/*
pub fn (s string) int() int {
return strconv.parse_int(s, 0, 32)
}
*/
pub fn (s string) int() int {
mut neg := false
mut i := 0
if s[0] == `-` {
neg = true
i++
}
else if s[0] == `+` {
i++
}
mut n := 0
for C.isdigit(s[i]) {
n = 10 * n - int(s[i] - `0`)
i++
}
return if neg { n } else { -n }
return int(strconv.parse_int(s,0,32))
}
pub fn (s string) i64() i64 {
return strconv.parse_int(s, 0, 64)
}
@@ -223,23 +203,7 @@ pub fn (s string) f64() f64 {
}
pub fn (s string) u32() u32 {
mut neg := false
mut i := 0
if s[0] == `-` {
neg = true
i++
}
else if s[0] == `+` {
i++
}
mut n := u32(0)
for C.isdigit(s[i]) {
n = u32(10) * n - u32(s[i] - `0`)
i++
}
return if neg { n } else { -n }
//return C.atol(*char(s.str))
//return strconv.parse_uint(s, 0, 32)
return u32(strconv.parse_uint(s, 0, 32))
}
pub fn (s string) u64() u64 {