Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

说说 Javascript 数字精度丢失的问题,如何解决? #395

Open
myselfwly opened this issue May 29, 2023 · 0 comments
Open

说说 Javascript 数字精度丢失的问题,如何解决? #395

myselfwly opened this issue May 29, 2023 · 0 comments

Comments

@myselfwly
Copy link

二、浮点数

  • 尾数写错了

在计算 27.5 的 尾数,原文是这个

因为它是十进制的需要转换为二进制,即 10000000011,小数部分为10111,补够52位即: 1011 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000`

但是在拼接的时候,原文是这个:

所以27.5存储为计算机的二进制标准形式(符号位+指数位+小数部分 (阶数)),既下面所示
0+10000000011+011 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000`

明显只有63位,尾数少拼接了一位,结果应该是:

0+10000000011+1011 1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant