int(0.25*4) gives 0
whilst
int(0.25000000000000000000001*4) gives 1
Think there is an issue here.

Indeed,

ttmath::ErrorCode parsingError = valueParser.Parse("0.25 * 4");
if (parsingError == ttmath::err_ok)
return valueParser.stack[0].value.ToInt();

also returns 0
; it should be 1 IMHO

Added by: tomek, 2010 XI 17, Last modified: 2010 XI 17

The simple answer is: 0.25 is not 0.25
TTMath is a binary library so decimal 0.25 has to be converted to binary and it is:
0.00111111111111111111111111111111111111111111111....
As you see there is not a finite binary representation. And we take only some first digits (depending on precision) let we say first 32 bits, so we have:
0.0011111111111111111111111111111111
and consequently it is not 0.25 but a little less.
And when you multiply it by 4 the result is not 1.

Small tips:
Print the result not as decimal but as binary:
std::string result = valueParser.stack.value.ToString(2);

Some more info:
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problem s