Matlab vs C++ Double Precision

后端 未结 2 1213
误落风尘
误落风尘 2020-11-28 15:57

I am porting some code from Matlab to C++.

In Matlab

format long
D = 0.689655172413793 (this is 1.0 / 1.45)
E = 2600 / D
// I get E          


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-28 16:40

    If I understand what you are trying to achieve, using ceil function might help:

    ans = ceil(ans); /* smallest integral value that is not less than ans. */
    // now ans in C++ is also be 3970.
    

    Here is usage reference.

提交回复
热议问题