Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
How do you round off a float?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Mike Hewson, post: 1524841"] Integer casts will truncate to the right of the decimal point. This suggests moving the point back and forth. *pseudocode* declare somenumber; // 3.1415 declare someprecision; // x, say equals 1. shifter = 10_to_the_power_of( someprecision ); shift_it = somenumber*shifter; truncate_it = integer_part_of( shift_it ); shift_it_back = truncate_it/shifter; // Result. *end pseudocode* [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
How do you round off a float?
Top