I wonder how I can get the fraction part of a float number. For example, I want to get the integer 75 of the float 56.75. Something like,
frac(56.75) = 75
Thanks in advance.
This is a discussion on How to get the fraction part of a float as an integer? within the C++ Programming forums, part of the General Programming Boards category; I wonder how I can get the fraction part of a float number. For example, I want to get the ...
I wonder how I can get the fraction part of a float number. For example, I want to get the integer 75 of the float 56.75. Something like,
frac(56.75) = 75
Thanks in advance.
Here's a rather hackish way....That should work for numbers with 2 after the decimal point....Code:int frac(double a) { int b; b = floor(a); b = (a-b) * 100; return b; }
-Govtcheez
govtcheez03@hotmail.com