diff --git a/builtin/string.v b/builtin/string.v index 1dc4734e2e..ba3caf433e 100644 --- a/builtin/string.v +++ b/builtin/string.v @@ -138,16 +138,12 @@ pub fn (s string) replace(rep, with string) string { return tos(b, new_len) } -fn (s string) to_i() int { +fn (s string) int() int { return C.atoi(s.str) } -fn (s string) int() int { - return s.to_i() -} - -fn (s string) i32() int { - return s.to_i() +fn (s string) f32() f32 { + return C.atof(s.str) } // == diff --git a/builtin/string_test.v b/builtin/string_test.v index 774d327461..d650cab2d4 100644 --- a/builtin/string_test.v +++ b/builtin/string_test.v @@ -251,16 +251,16 @@ fn test_arr_contains() { fn test_to_num() { s := '7' - assert s.to_i() == 7 + assert s.int() == 7 f := '71.5 hasdf' - assert f.to_float() == 71.5 + assert f.f32() == 71.5 b := 1.52345 mut a := '${b:.03f}' assert a == '1.523' num := 7 a = '${num:03d}' vals := ['9'] - assert vals[0].to_i() == 9 + assert vals[0].int() == 9 } fn test_hash() { @@ -289,4 +289,4 @@ fn test_all_after() { s := 'fn hello' q := s.all_after('fn ') assert q == 'hello' -} \ No newline at end of file + diff --git a/http/http_mac.v b/http/http_mac.v index 5cdf19e925..a5702370ff 100644 --- a/http/http_mac.v +++ b/http/http_mac.v @@ -156,7 +156,7 @@ fn (req &Request) do() Response { mut status_code := 0 if first_header.contains('HTTP/') { val := first_header.find_between(' ', ' ') - status_code = val.to_i() + status_code = val.int() } // Build resp headers map // println('building resp headers hchunk.strings.len') diff --git a/time/time.v b/time/time.v index 9e068274ea..43b988f6e6 100644 --- a/time/time.v +++ b/time/time.v @@ -260,12 +260,12 @@ pub fn parse(s string) Time { second := hms[2] // ////////// return new_time(Time { - year: ymd[0].to_i() - month: ymd[1].to_i() - day: ymd[2].to_i() - hour: hour.to_i() - minute: minute.to_i() - second: second.to_i() + year: ymd[0].int() + month: ymd[1].int() + day: ymd[2].int() + hour: hour.int() + minute: minute.int() + second: second.int() }) }