Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get integer before float's decimal point (Objective-c)

Tags:

objective-c

I have a float like so 23.248500. Is it possible for me to just get the 23 part and the 0.248500 part separately?

Thanks

like image 701
CoreCode Avatar asked Nov 30 '22 06:11

CoreCode


1 Answers

For positive numbers, you can use floor(f) function to get 23, and f - floor(f) to get the 0.248500 part.

(I linked C++ reference, but the same function is present in the C library).

like image 147
Sergey Kalinichenko Avatar answered Dec 04 '22 07:12

Sergey Kalinichenko