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

[js] 第672天 请说说IEEE 754标准指的是什么? #3570

Open
haizhilin2013 opened this issue Feb 15, 2021 · 1 comment
Open

[js] 第672天 请说说IEEE 754标准指的是什么? #3570

haizhilin2013 opened this issue Feb 15, 2021 · 1 comment
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第672天 请说说IEEE 754标准指的是什么?

3+1官网

我也要出题

@haizhilin2013 haizhilin2013 added the js JavaScript label Feb 15, 2021
@fayeah
Copy link

fayeah commented Feb 20, 2021

IEEE 754, IEEE二进制浮点数算术标准,是使用最广泛的浮点数运算标准。很多语言都采用了该标准,包含JavaScript、Java等。但是该计算标准有一个缺陷,就是浮点数相加可能会出现误差,比如:
image

所以,在编写程序的时候,尽量不要使用浮点数的算式来进行比较,很容易出错:

float a = 0.15 + 0.15
float b = 0.1 + 0.2
if(a == b) // can be false!
if(a >= b) // can also be false!

参考:

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

No branches or pull requests

2 participants