diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-13 13:59:35 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-13 13:59:35 -0500 |
| commit | c5878cced02fd1ed7e7940eaf8eb8b4cce23a9d4 (patch) | |
| tree | 71ce75113224e438532851f9a676433803e12c8a /src/stdlib | |
| parent | ceb375c0835e2d501550e1f1228184662415ef8e (diff) | |
Fix some Real issues
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/reals.c | 9 |
1 files changed, 7 insertions, 2 deletions
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); |
