fengb / fengb/zasp

Smarter `number(float)` buffer

Open
#1 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
17
Forks
1
PR merge metrics
No merged PRs in 30d

Description

The code currently handles floats by using a 4096 buffer space. We can do better:

- There are 2 main pieces to floats: mantissa + exponent. Both are known to be limited.
- Max length should be max digits of mantissa + max digits of exponent + formatting flags

Thoughts on a limiting parser:
1. Fill up the buffer until mantissa is full
2. If mantissa is full, don't append into buffer. If we didn't see a decimal, keep accruing the digit overflow; this is going to append to the actual exponents.
3. If we find `e`, treat the next set of digits as exponents.
4. Toss this result weird monstrosity result into `parseFloat`

I believe `parseFloat` should handle all of these edge cases already, in which case it could possibly be adapted to understand a `reader` instead of just strings. So maybe we could push an update to stdlib.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.