round-to-nearer-integer ?

P

Patrick Guio

Dear all,

Are round-to-nearer-integer type C functions (like
round, lround, rint, etc...) defined in the std namespace when including
<cmath>?
If not would "static_cast<int>(x+0.5)" do a good solution as a
replacement for rint(x) ?

Sincerely, Patrick
 
V

Victor Bazarov

Patrick said:
Are round-to-nearer-integer type C functions (like round, lround, rint,

No such functions in C++. You must be using some library extension
that doesn't exist everywhere.
etc...) defined in the std namespace when including <cmath>?

They probably aren't, since I know of no such functions.
If not would "static_cast<int>(x+0.5)" do a good solution as a
replacement for rint(x) ?

Possibly. For positive 'x', probably. Have you tried 'floor' or
'ceil' functions? Have you tried searching on Google Groups for
"round double int" or something like that?

V
 

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
474,201
Messages
2,571,049
Members
47,655
Latest member
eizareri

Latest Threads

Top