aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-13 13:59:35 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-13 13:59:35 -0500
commitc5878cced02fd1ed7e7940eaf8eb8b4cce23a9d4 (patch)
tree71ce75113224e438532851f9a676433803e12c8a /src
parentceb375c0835e2d501550e1f1228184662415ef8e (diff)
Fix some Real issues
Diffstat (limited to 'src')
-rw-r--r--src/environment.c1
-rw-r--r--src/stdlib/reals.c9
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);