Search code examples
floating-pointdecimal-point

Multiply by decimal by number of decimal places


I need a way to multiple the a float by the number of decimal places.

e.g.

Number = 10.04
Number of Decimal Places = 2
Result = 1004

Number = 123.421
Number of Decimal Places = 3
Result = 123421

so on and so forth, I have a method written to return the number of decimal places, but how can I expected result as mentioned above?


Solution

  • Are you just moving the decimal point? If so... #EDITTED# result = number * (10 to the power of decimal places)