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.

Printable View

- 10-02-2001A. MotazHow to get the fraction part of a float as an integer?
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. - 10-02-2001Govtcheez
Here's a rather hackish way....

Code:`int frac(double a)`

{

int b;

b = floor(a);

b = (a-b) * 100;

return b;

}