Repository navigation
Commit ad7331a
fix(formula): decimal text is judged against the number range before it is scaled (#34570)
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:`toScaledDecimal`
先按数值范围判定十进制文本,再做缩放。超出范围的文本读为无值,低于最小数的文本读为零,零不再按其指数缩放;范围内每一位仍精确保留。
- 为什么改:同一个值以文本和以数字传入时,判定结果必须一致。
- 风险与回滚:范围内的读取不变,数字和 bigint 的读取不变,`divideToPlaces` 与
`formatScaledDecimal` 不变。回滚即 revert 本 PR。
- 先看:`packages/formula/src/home-amount-arithmetic.ts` 的
`toScaledDecimal`。
- 需要你做的:无,席位落地。
## What changes
`toScaledDecimal` (`@objectstack/formula`) judges decimal text against
the number range before it scales it, the way the same value is judged
as a number:
- Text whose number is not finite spells no decimal and reads
`undefined`, as a non-finite number already did.
- Text whose number is zero because it is below the smallest number
reads as zero, as that number already did.
- A zero is never scaled by its exponent.
Inside the range every digit is still kept exactly. The home-amount
projection treats an amount that spells no decimal as before: it leaves
the value to the record validator.
## Tests
`packages/formula/src/home-amount-arithmetic.test.ts`: text above the
range reads `undefined`; text below the smallest number reads zero,
either sign; a zero with an exponent reads plain zero; in-range text
keeps every digit (control). The implementer's suite, gate and ablation
readings were read by the security#1 seat (brief 6934902629); this PR is
opened by the security#2 seat after that seat's clock-out.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj)_
<!-- signed: security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 066177b commit ad7331a
3 files changed
Lines changed: 105 additions & 4 deletions
File tree
- .changeset
- packages/formula/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
35 | 50 | | |
36 | 51 | | |
37 | 52 | | |
| |||
49 | 64 | | |
50 | 65 | | |
51 | 66 | | |
52 | | - | |
53 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
54 | 79 | | |
55 | 80 | | |
56 | 81 | | |
| |||
76 | 101 | | |
77 | 102 | | |
78 | 103 | | |
79 | | - | |
| 104 | + | |
| 105 | + | |
80 | 106 | | |
81 | 107 | | |
82 | 108 | | |
| |||
0 commit comments