diff options
| -rw-r--r-- | src/environment.c | 1 | ||||
| -rw-r--r-- | src/stdlib/reals.c | 9 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/environment.c b/src/environment.c index 4cb7fbb0..d1618d9a 100644 --- a/src/environment.c +++ b/src/environment.c @@ -686,6 +686,7 @@ env_t *get_namespace_by_type(env_t *env, type_t *t) { case IntType: case BigIntType: case FloatType: + case RealType: case ByteType: { binding_t *b = get_binding(env, Text$as_c_string(type_to_text(t))); assert(b); diff --git a/src/stdlib/reals.c b/src/stdlib/reals.c index ba088bb6..40f4cf4c 100644 --- a/src/stdlib/reals.c +++ b/src/stdlib/reals.c @@ -61,8 +61,13 @@ OptionalReal_t Real$parse(Text_t text, Text_t *remainder) { Text_t fraction_text = EMPTY_TEXT; if (Text$starts_with(decimal_onwards, Text("."), &fraction_text)) { fraction_text = Text$replace(fraction_text, Text("_"), EMPTY_TEXT); - OptionalInt_t fraction = Int$parse(fraction_text, I(10), remainder); - if (fraction.small == 0) return NONE_REAL; + OptionalInt_t fraction; + if (fraction_text.length == 0) { + fraction = I(0); + } else { + fraction = Int$parse(fraction_text, I(10), remainder); + if (fraction.small == 0) return NONE_REAL; + } int64_t shift = fraction_text.length; Int_t scale = Int$power(I(10), I(shift)); Int_t i = Int$plus(Int$times(int_component, scale), fraction); |
