# Can this simple percentage calculator be further optimized?

public double getValueWithPercentage(double number, double percentage)
{
return number + ((percentage / 100.0) * number);
}


Are there any tricks to optimize this simple code?

## migrated from stackoverflow.comJan 12 '12 at 4:41

This question came from our site for professional and enthusiast programmers.

• What lead you to believe that this method may need optimising? – Tim Cooper Jan 11 '12 at 23:49
• are you talking about performance optimization, or precision increase? which are the variable ranges? – djjeck Jan 11 '12 at 23:53
• I think it's worth noting a few things. 1. Multiplication is faster than division. 2. Bitshifting, or Bitwise operations, will not be faster since most compilers perform this for you 3. Unless you are working with VERY large numbers, aka BigInteger, you won't see improvements with multiplication algorithms like Schönhage–Strassen. – Tony R Jan 12 '12 at 20:27

public double getValueWithPercentage(double number, double percentage)