Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding real to integer 1

Status
Not open for further replies.

johnnydarten

Programmer
Jan 7, 2012
5
EG
Dear All,

I just want to know how to turn a "real" number to "integer" number by rounding it(not ceiling nor floor!!).
Is the built-in function round used for that in C++ applicable here?

regards,
Johnnydarten

 
also, in case it helps:-


NINT rounds UP or DOWN (i.e. to the Nearest INTeger, hence the name)
INT rounds TOWARD ZERO (i.e. ABS(INT(A)) <= ABS(A))


for example
NINT ( 7.8) = 8
INT ( 7.8) = 7

NINT (-7.8) = -8
INT (-7.8) = -7

at least, that's how it was taught to me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top