Asked by C Zeng
on 23 Oct 2012

floor(1.999999999999)=1 floor(1.99999999999999999999999999)=2, why is that?

Floor should return the lower integer right? Thanks.

*No products are associated with this question.*

Answer by Matt J
on 23 Oct 2012

Edited by Matt J
on 23 Oct 2012

Accepted answer

If that confuses you, this probably will too:

>> isequal(1.99999999999999999999999999, 2)

ans =

1

Anyway, it has nothing to do with the FLOOR command. It's because your big long decimal can't be distinguished from 2 in floating point.

Show 3 older comments

Matt J
on 23 Oct 2012

This one contains an overloaded floor function, if that's what you mean

http://www.mathworks.com/matlabcentral/fileexchange/6446-multiple-precision-toolbox-for-matlab

Answer by Azzi Abdelmalek
on 23 Oct 2012

Just try without floor

a=1.99999999999999999999999999

Show 5 older comments

Azzi Abdelmalek
on 23 Oct 2012

Walter Roberson
on 23 Oct 2012

Opportunities for recent engineering grads.

## 0 Comments