I have old pascal code
var i : longint;
m : double;
begin
.....
i := trunc(m);
I have to convert it to C++ code.
An obvious thing here is to write
double m;
int i;
.....
i = static_cast<int>(std::trunc(m));
But the problem here is than pascal's trunc retus integer
function trunc(
d: ValReal
):Int64;
while c++'s trunc retus double. Is it possible that for example trunc(2.3) will retu 1.999999999999 and static_cast will make it 1 instead of 2? If yes is it correct to use static_cast without trunc to get same pascal's behavior?
i = static_cast<int>(m);
