Im trying to find a interest rate in my program. I need it to accept values like 6.9%. How do I multiply a number by a percent. Thanks
Printable View
Im trying to find a interest rate in my program. I need it to accept values like 6.9%. How do I multiply a number by a percent. Thanks
If you have a float with a percentage (like 6.9) in it, and call the percentage variable something like fPercent, you can do it like this:
Code:fSmallValue = fLargeValue * fPercent/100.0f
that works great, thanks.
If you want to try and preserve as much accuracy as possible:Code:fSmallValue = (fLargeValue * fPercent) / 100.0f;
If you want to preserve as much accuracy as possible, use doubles :rolleyes: