Objective-C round functions

Essentials for this time!

How to round float values? Neither Stack Overflow topic has the full answer.

Generally, to round float-value and get int-value you can use lroundf (). Like this:

long int lroundf (float x);

Look Apple Developer Man for round () details.

By the way, for simple output rounded float, use token: @.0f

Also these functions are useful:

ceil (float x);
floor (float x);

NSNumber, float, double, etc. is also applicable.

Drunk owl.
Поделиться
Отправить
Запинить
Популярное