PDA

Click to See Complete Forum and Search --> : percentage


MPrestonf12
May 20th, 2001, 11:02 AM
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

HarryW
May 20th, 2001, 11:12 AM
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:
fSmallValue = fLargeValue * fPercent/100.0f

MPrestonf12
May 20th, 2001, 11:14 AM
that works great, thanks.

parksie
May 20th, 2001, 11:27 AM
If you want to try and preserve as much accuracy as possible:fSmallValue = (fLargeValue * fPercent) / 100.0f;

HarryW
May 20th, 2001, 11:31 AM
If you want to preserve as much accuracy as possible, use doubles :rolleyes: