floating point round in C++

J

John Smith

Hello, is there a way to implement the floating point version of round?
usually for int's it's int(num+.5) but how to do it for floats?

Thanks.
 
T

Thomas Wintschel

John Smith said:
Hello, is there a way to implement the floating point version of round?
usually for int's it's int(num+.5) but how to do it for floats?

Thanks.

#include <math.h>

double d = floor(num+.5);
 
J

Juergen Heinzl

Hello, is there a way to implement the floating point version of round?
usually for int's it's int(num+.5) but how to do it for floats?
[-]
Yeah ...

int(4.49 + 0.5)

.... sure 8-}

Just let me know which bank you're working for lest I'm opening
an account there.

Cheers,
Juergen

PS: C99 knows of round(double) and roundf(float).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top