In my book it said that i can use this
cout.setf(ios::fixed, ios::floatfield);
cout.precision(2);
But what if i want to round it off to the nearest 0.50?
like double Cash = 10.34 will be 10.50
Thanks.
In my book it said that i can use this
cout.setf(ios::fixed, ios::floatfield);
cout.precision(2);
But what if i want to round it off to the nearest 0.50?
like double Cash = 10.34 will be 10.50
Thanks.
Last edited by major_small; 11-20-2003 at 08:28 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
I/O functions don't do math. Just round it manually.
Code:double round(double number) { double change = number - (int)number; number -= change; if(change < 0.25) change = 0; else if(change > 0.75) change = 1; else change = 0.50; return number + change; }
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }