Is there a quicker way?

# Thread: Is there a quicker way?

1. Senior Member
Join Date
Dec 1969
Posts
2,880

## Is there a quicker way?

Hi Guys,<BR><BR>Is there a quicker way to calculate a percentage of a value e.g.<BR><BR>\$100 * 10% should equal to \$110<BR><BR>My Code:<BR>(RS("SAmount") * RS("SPercent")) / 100<BR><BR>Thanks!

2. Senior Member
Join Date
Dec 1969
Posts
2,958

## RE: Is there a quicker way?

How much faster do you think you can do it?<BR><BR>But why are you dividing by 100?<BR><BR>\$100 * 10% = \$10 now you need to add the 2 yes? Dividing \$10 by 100 will get you .10 <BR><BR>Try a plain old calculator

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Tch tch! Shame on Doug!

Doug, you have forgotten 6th grade arithmetic!<BR><BR>The way you multiply by a percentage is...<BR><BR>Divide the percentage by 100 to get a fraction and then multiply by the fraction.<BR><BR>No, Trippy, there is no better way. Except that you are wrong about <BR> \$100 * 10% = \$110<BR><BR>NOT TRUE!<BR> \$100 * 10% = \$10<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Why do you need quicker???

If you are doing that in VB (not VBS) code, then the extra divide by 100 takes maybe a tenth of a microsecond or so.<BR><BR>Maybe.<BR><BR>[hl="yellow"]\$100 * 10% should equal to \$110[/hl]<BR><BR>No, it should not. 10% of \$100 is only \$10.<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## By the way...

Doug, I agree with you.<BR><BR>Try a PLAIN old calculator.<BR><BR>One that does *NOT* have a % key on it.<BR><BR>[by the way, I don&#039;t understand what you meant by "now you need to add the 2". Two what?]<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
2,958

## Ashamed

Have a cold will you buy that?<BR><BR>As for the add the 2 ... I thought he wanted a total of the 2. Like adding sales tax to the amount to get a total.

7. Join Date
Dec 1969
Posts
90

## basic math

x + (x * 10)/100 <BR>where x could be \$100 and 10 is the %..

8. Senior Member
Join Date
Dec 1969
Posts
2,958

## Hey wait!

He&#039;s dividing the ***RESULT*** of the amount * percent by 100<BR><BR>I may have a bad cold but that would be, in his example, <BR><BR>(\$100 * 10%) / 100 = \$10<BR><BR>so why the division by 100????

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## Order doesn't matter...

( A * B ) / C === A * B / C === A * ( B / C ) === ( A / C ) * B<BR><BR>You can do the division before or after, makes no difference.<BR><BR>Try it yourself. On your calculator, if you wish.<BR><BR>Oh heck, I&#039;ll do it:<BR><BR>10% of \$100:<BR><BR>(100 * 10) / 100 --&#062;&#062; (1000) / 100 --&#062;&#062; 10<BR>100 * ( 10 / 100 ) --&#062;&#062; 100 * ( 0.1 ) --&#062;&#062; 10<BR>(100 / 100 ) * 10 --&#062;&#062; (1) * 10 --&#062;&#062; 10<BR><BR>See?<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## But that's NOT what she asked for

She neither asked for the sum of the percentage plus the original nor did she show code that would do that.<BR><BR>She only asked how to get the percentage faster.<BR><BR>Granted, maybe that&#039;s what she *MEANT*, since Trippy tends to be sloppy in what she asks for, but I wasn&#039;t ready to presume that.<BR><BR>And you could also do<BR> (x / 100) * ( 100 + pct)<BR>or<BR> x * ( 1 + pct/100 )<BR>or variations on that theme.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•