|
-
May 20th, 2001, 11:02 AM
#1
Thread Starter
Hyperactive Member
percentage
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
Matt 
-
May 20th, 2001, 11:12 AM
#2
Frenzied Member
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
Harry.
"From one thing, know ten thousand things."
-
May 20th, 2001, 11:14 AM
#3
Thread Starter
Hyperactive Member
that works great, thanks.
Matt 
-
May 20th, 2001, 11:27 AM
#4
Monday Morning Lunatic
If you want to try and preserve as much accuracy as possible:
Code:
fSmallValue = (fLargeValue * fPercent) / 100.0f;
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
May 20th, 2001, 11:31 AM
#5
Frenzied Member
If you want to preserve as much accuracy as possible, use doubles
Harry.
"From one thing, know ten thousand things."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|