[SOLVED] How to limit Floting piont

Status
Not open for further replies.
Hello!

If you want to "truncate" it for example after 2 decimals, why not this:

float a = 3.2335998798;

float b = 100 * a; // 323.35...

int32 c = (int)b;

a = c/100;

Now if you simply want to display it you should consider using the right format for printf (or sprintf).
It's all in man printf.

Dora
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…