3
votes

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

1 Answers

6
votes

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.