diff options
Diffstat (limited to 'src/gleam__stdlib.erl')
-rw-r--r-- | src/gleam__stdlib.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gleam__stdlib.erl b/src/gleam__stdlib.erl index 7ee4ba8..05623c6 100644 --- a/src/gleam__stdlib.erl +++ b/src/gleam__stdlib.erl @@ -6,7 +6,7 @@ atom_create_from_string/1, atom_to_string/1, map_fetch/2, iodata_append/2, iodata_prepend/2, identity/1, decode_int/1, decode_string/1, decode_bool/1, decode_float/1, decode_thunk/1, - decode_tuple/1, decode_list/1, decode_field/2, parse_int/1]). + decode_tuple/1, decode_list/1, decode_field/2, parse_int/1, parse_float/1]). expect_equal(Actual, Expected) -> ?assertEqual(Expected, Actual). expect_not_equal(Actual, Expected) -> ?assertNotEqual(Expected, Actual). @@ -78,3 +78,12 @@ parse_int(String) -> _ -> {error, parse_error} end. + +parse_float(String) -> + case string:to_float(binary:bin_to_list(String)) of + {Float, []} -> + {ok, Float}; + + _ -> + {error, parse_error} + end. |