View Single Post
Old Jan 30th, 2007, 2:04 AM   #1
kurt
Programmer
 
Join Date: Oct 2005
Posts: 68
Rep Power: 3 kurt is on a distinguished road
Arithmetic By Percentage

Let's say i want to perform a subtraction on a variable (say, Energy) by 5%, the shortest way i can think of is:

Tolerance = 0.05 * Energy
Energy = Energy - Tolerance
or

Energy = Energy - 0.05*(Energy)
I know it's already pretty short, but is there a shorter, elegant way?
kurt is offline   Reply With Quote