Objective-c – Get the Decimal part out of a float number

floating pointobjective cxcode

I need to get the decimal part out of a float number, for example:

float x = 18.30;

I need a way to get the '.30' in another float.. so I will have a float equals to 18.30 and another one equals to .30

Any ideas?

Best Answer

I'm not sure if there is a function doing exactly the way you want but you can use this:

x - floor(x)