2022-01-13 05:24:03 +01:00
|
|
|
function string_decimal(str) {
|
2023-01-17 08:11:55 +01:00
|
|
|
var neg = string_char_at(str, 1) == "-";
|
|
|
|
if(neg) str = string_copy(str, 2, string_length(str) - 1);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
var dec = string_pos(".", str);
|
|
|
|
var pre = string_copy(str, 1, dec - 1);
|
|
|
|
var pos = string_copy(str, dec + 1, string_length(str) - dec);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
return (neg? "-" : "") + (dec? string_digits(pre) + "." + string_digits(pos) : string_digits(str));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function toNumber(str) {
|
2023-01-17 08:11:55 +01:00
|
|
|
if(is_real(str)) return str;
|
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
str = string_decimal(str);
|
|
|
|
if(str == "") return 0;
|
|
|
|
if(str == ".") return 0;
|
2022-12-18 03:20:38 +01:00
|
|
|
if(str == "-") return 0;
|
2022-01-13 05:24:03 +01:00
|
|
|
return real(str);
|
|
|
|
}
|