About floor function problem.
古いコメントを表示
floor(1.999999999999)=1 floor(1.99999999999999999999999999)=2, why is that?
Floor should return the lower integer right? Thanks.
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2012 年 10 月 23 日
Just try without floor
a=1.99999999999999999999999999
8 件のコメント
C Zeng
2012 年 10 月 23 日
Azzi Abdelmalek
2012 年 10 月 23 日
編集済み: Azzi Abdelmalek
2012 年 10 月 23 日
I mean you don't need to floor it, you will find 2
C Zeng
2012 年 10 月 23 日
Azzi Abdelmalek
2012 年 10 月 23 日
編集済み: Azzi Abdelmalek
2012 年 10 月 23 日
Zeng. from where did you get 1.999999999999999? knowing that matlab don't allow it
C Zeng
2012 年 10 月 23 日
Azzi Abdelmalek
2012 年 10 月 23 日
I am not sur what you mean by converting to 2 digits, I think, with 2 digits, you will have four possible digital numbers, And you need a min and max value to be able to do this conversion. Can you explain, or post another question?
Walter Roberson
2012 年 10 月 23 日
If you are starting with an integer, then dividing by a power of 2 can never result in this kind of round-off. Powers of 2 are represented exactly in binary floating point numbers, and dividing by a power of two effectively only changes the internal binary exponent without changing the mantissa. If you are running into this kind of round-off then either you are not starting with an integer or you are not dividing by a power of 2.
C Zeng
2012 年 10 月 26 日
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!