please, how do i fix a number in c++,
my problem is that a float number returns me a lot of decimals that i do not need to display so I want to cut those off the number
please, how do i fix a number in c++,
my problem is that a float number returns me a lot of decimals that i do not need to display so I want to cut those off the number
use setprecision... I forgot the code and dont have any access to any of the programs i've written with it in there tho... but you can look it up...
//edit: setprecision doesn't round the number, it truncates... i.e.:
with setprecision set to two ( cout<<setprecision(2); ):
6.1564 = 6.15
6.150041 = 6.15
483.480001 = 183.48
483.4863487 = 483.48
Last edited by major_small; 10-15-2003 at 06:09 AM.
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
major_small, you mean to tell me that you don't remember the majic formula that every programmer should recite without hesitation when waken up in the middle of the night??? just kidding, heheOriginally posted by major_small
use setprecision... I forgot the code and dont have any access to any of the programs i've written with it in there tho... but you can look it up...
axonCode:cout.setf(ios::showpoint); cout.setf(ios::fixed); cout.precision(/*number of digitts here*/);
EDIT:: BTW this is within iomanip lib
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
^haha... i haven't used it in so long... i was actually the only one to memorize it in my high school programming class...
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
i thought Set precision does round numbers off... it does when i do it.