Hi, just wondering if there is away of telling if a number is fractional or not. I have a double variable which is being divided several times, the result of which needs to be known whether it is whole or fractional. You can’t use the % mod operator on floating point numbers.
The most likely way would be to do something like this:
The only trouble with this method is the unsigned long can only store unsigned numbers up to 4,294,967,295, therefore assigning Result to Whole would be out of range. Can anyone help us with this? There must be a way to find out if Result is fractional or not.Code:unsigned long Whole; double Temp = 1789664465465, Result; Result = Temp / 2; Whole = Temp //truncate value if(Whole – Result == 0) //Result must be a whole number { //do whatever }