You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
amis-formula: UPPERMONEY and CEIL give wrong results from float multiplication (UPPERMONEY(19.99) gives 壹拾玖元玖角捌分, CEIL(1.1, 2) gives 1.11) #21533
UPPERMONEY and CEIL multiply by a power of ten and then floor or ceil the result. In binary floating point, 19.99 * 100 is slightly less than 1999 and 1.1 * 100 is slightly more than 110, so the last digit comes out wrong. #12232 / #12239 fixed this for FLOOR by rounding a * c with toFixed(10), but CEIL and UPPERMONEY still use the unrounded product.
Also, when 角 is zero and 分 is non-zero, UPPERMONEY drops 零: UPPERMONEY(1.05) returns 壹元伍分 and UPPERMONEY(100.05) returns 壹佰元伍分 instead of 壹元零伍分 and 壹佰元零伍分.
截图或视频:
N/A
如何复现(请务必完整填写下面内容):
你是如何使用 amis 的? npm (amis-formula)
amis 版本是什么?请先在最新 beta 版本测试问题是否存在 amis-formula@6.13.0 (latest; also on master43a33ee in packages/amis-formula/src/evalutor.ts)
操作步骤
Run the snippet above with node after npm install amis-formula@6.13.0. Out of all cent amounts from 0.01 to 999.99, 7,669 produce the wrong 角 or 分 digit in fnUPPERMONEY (Math.floor(n * 10 * Math.pow(10, i)) % 10), and fnCEIL (Math.ceil(a * c) / c) rounds up exact two-decimal numbers whenever a * c has a positive float tail.
Activity
github-actions commentedon Nov 14, 2026
👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.
Please review the labels and make any necessary changes.
go-888 commentedon Nov 20, 2026
项目都停更了, 你还发这个.
fix: 修复 amis 表达式 CEIL/UPPERMONEY 浮点乘法导致的计算错误 Close: baidu#21533
fix: 修复 amis 表达式 CEIL/UPPERMONEY 浮点乘法导致的计算错误 Close: baidu#21533