Commit 3a818de
authored
fix(v4): handle multi-digit exponents in floatSafeRemainder (#5687)
* fix(v4): handle multi-digit exponents in floatSafeRemainder
The regex `/\d?e-\d?/` only matches single-digit exponents, causing
`multipleOf` validation to fail for steps like `1e-10` or smaller.
For example, with `step = 1e-10`:
- The regex matched `"1e-1"` instead of `"1e-10"`
- Captured exponent was `"1"` instead of `"10"`
- This caused incorrect decimal count, leading to NaN remainder
Changed `\d?` to `\d+` to capture multi-digit exponents correctly.
Bug discovered by whiterose (https://github.com/shakecodeslikecray/whiterose)
* test: add regression test for multipleOf with scientific notation
Ensures multipleOf correctly handles steps with multi-digit exponents
like 1e-10 and 1e-15.
This test would fail before the regex fix in floatSafeRemainder.1 parent 55747b3 commit 3a818de
2 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
156 | 172 | | |
157 | 173 | | |
158 | 174 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
| 251 | + | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| |||
0 commit comments