October 29th, 2012, 12:47 PM
Whole number check
Is there an easy way to check if the result of a calculation (bv 10 / 9 or 10 / 5) is a whole number or not?
October 29th, 2012, 01:01 PM
[/code] are essential for python code and Makefiles!
October 29th, 2012, 01:44 PM
The result of integer division (as in your exemple) (except division by zero) is ALWAYS an integer.
Originally Posted by KevinFCTwente
The result of floating-point division (except division by zero and overflows) is always a floating-point number.
If you want to determine if a floating point number has the same value as a whole number, that's another problem:
for instance 4.2E-289 is not a whole number (zero?) but 4.2E289 is a whole number.
October 29th, 2012, 01:50 PM
In simple math...
if (numerator == (numerator/denominator)*denominator) then the result of numerator/denominator is a whole number ;
else it isn't ;
Do you agree? Disagree? And remember, it's all about the reputation power...