Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > floating point round in C++

Reply
Thread Tools

floating point round in C++

 
 
John Smith
Guest
Posts: n/a
 
      12-14-2003
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.


 
Reply With Quote
 
 
 
 
Thomas Wintschel
Guest
Posts: n/a
 
      12-14-2003
"John Smith" <(E-Mail Removed)> wrote in message
news:brinrm$19g6$(E-Mail Removed)...
> 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);


 
Reply With Quote
 
 
 
 
Juergen Heinzl
Guest
Posts: n/a
 
      12-14-2003
In article <brinrm$19g6$(E-Mail Removed)>, John Smith wrote:
> 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).

--
\ Real name : Juergen Heinzl \ no flames /
\ EMail Private : http://www.velocityreviews.com/forums/(E-Mail Removed) \ send money instead /
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
round the floating point to nearest halfpoint Lucky Nl Ruby 2 05-26-2010 01:13 PM
converting floating point types round off error .... ma740988 C++ 13 12-14-2008 10:02 AM
How to round a floating point to nearest 10? Will Rocisky Python 7 08-09-2008 10:38 PM
Newby - how to round up floating point number? Dermot Moynihan Ruby 9 01-06-2007 10:24 PM



Advertisments