Jump to content
  • Advertisement

Archived

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

XDarkScar

Adding 25% to something

This topic is 5529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im sry that this is such a noob question, but how? Easy way of programming: Code, Graphics, Swearing....

Share this post


Link to post
Share on other sites
Advertisement
If you mean C/C++, then

  
something = (something * .25)+ something;

should work.

Curse you windows and your poor explanation of my errors!!!

Share this post


Link to post
Share on other sites
I would just use:

somenumber*=1.25;


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

Dwiel

Share this post


Link to post
Share on other sites
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
Um, no. It'll expand to

someNumber = someNumber*1.25;

edit. Beat me to the punch!

[edited by - kordova on May 4, 2003 9:16:59 PM]

Share this post


Link to post
Share on other sites
Yay.... Basic Algebra!



- Rob Loach
Current Project: Go Through Object-Oriented Programming in C++ by Robert Lafore

"Do or do not. There is no try."
- Yoda

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!