Archived

This topic is now archived and is closed to further replies.

XDarkScar

Adding 25% to something

Recommended Posts

quote:
Original post by Tazzel3D
I would just use:

somenumber*=1.25;


a little less typing if the variable name is long...

Dwiel



Umm that won''t work. It''ll expand to
somenumber=somenumber*1.25 + somenumber
which isn''t correct
you should have
somenumber*=0.25

Share this post


Link to post
Share on other sites
quote:
Original post by RamboBones
Umm that won't work. It'll expand to
somenumber=somenumber*1.25 + somenumber
which isn't correct
you should have
somenumber*=0.25

What are you talking about? somenumber*=1.25 is correct. It works just like ALL the other in-place arithmetic operators.


  
#include <iostream>

using namespace std;

int main()
{
float a = 4;
a *= 1.25;
cout << a << endl;
}

Outputs 5.


How appropriate. You fight like a cow.

[edited by - sneftel on May 4, 2003 9:17:31 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by RamboBones
the middle of the morning

Hee hee... you wacky foreigners, with your screwed up clocks! pants


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites