Matlab/Octave addition, losing digits of precision

非 Y 不嫁゛ 提交于 2019-12-07 17:29:39

问题


In Matlab/octave, when I add two numbers, I am losing some of my digits.

>>> 23.0 + 0.65850
ans =  23.659

How do I get back a double that is 23.65850?


回答1:


The number is being rounded only for display purposes. Take a look at the format command if you wish to change it.

octave> 23 + 0.65850
ans =  23.659
octave> format free
octave> 23 + 0.65850
ans = 23.7
octave> format long g
octave> 23 + 0.65850
ans =              23.6585

Take a look at help format for the other options but remember, that this only affects the display. You are not losing any precision.



来源:https://stackoverflow.com/questions/13886821/matlab-octave-addition-losing-digits-of-precision

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!