0.14*100~=14

2 views (last 30 days)
Wang Zhongwei
Wang Zhongwei on 29 Apr 2021
Commented: Star Strider on 29 Apr 2021
if you run the following code,you will find the answer is not as you think:
a=0.14*100-14;
then a is not equal to zero,why?

Accepted Answer

Star Strider
Star Strider on 29 Apr 2021
Not a bug!
See Floating-Point Numbers for a detailed discussion.
  2 Comments
Wang Zhongwei
Wang Zhongwei on 29 Apr 2021
thank you!The answer is useful!
Star Strider
Star Strider on 29 Apr 2021
As always, my pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!