Normal Topic percentages (Read 1206 times)
billgordon
Junior Member
**
Offline


No personal text

Posts: 61
Joined: Dec 31st, 2003
percentages
Jul 14th, 2005 at 10:07pm
Print Post Print Post  
In calculating percent I seem to have a problem. I am using this percent = (@tomoney(Salary)) /(@tomoney(classamount)) Salary is a money field type in this example salary is 50,000.00 and classamount is a money field type, In this example classamount is 100,000.00. my belief is that 50,000.00 divided by 100,000.00 = 50% the computer shows 0.50 which is not a huge deal but when numbers are inverted 190,000.00 divided by 220,000.00 = 116% the computer shows 1.16 which is confusing. What can I do to fix this? Thank you.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: percentages
Reply #1 - Jul 14th, 2005 at 10:17pm
Print Post Print Post  
Multiply by 100.

percent = (@tomoney(Salary)) /(@tomoney(classamount)) * 100
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bob_Hansen
Senior Member
Members
*****
Offline


WOW, They have the Internet
on computers now!

Posts: 1861
Location: Salem, NH
Joined: Nov 24th, 2002
Re: percentages
Reply #2 - Jul 15th, 2005 at 3:17am
Print Post Print Post  
Quote:
190,000.00 divided by 220,000.00 = 116% the computer shows 1.16 which is confusing. What can I do to fix this?
confuses me too.  I get .8636 vs. 1.16.   Roll Eyes 

But multiplyiing by 100 does result in 86.36 Grin
  



Bob Hansen
Sesame Database Manager Professional
Sensible Solutions Inc.
Salem, NH
603-898-8223
Skype ID = sensiblesolutions
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: percentages
Reply #3 - Jul 15th, 2005 at 7:12pm
Print Post Print Post  
Quote:
Multiply by 100.

percent = (@tomoney(Salary)) /(@tomoney(classamount)) * 100


Playing with yesterdays post on percentages I tried to use what was shown and now I find myself on the confused side.

Take Bills example:

percent = (@tomoney(Salary)) /(@tomoney(classamount)) * 100

50,000.00 / 100,000.00 * 100 = 50%

That looks nice, but if you use:

50,000.00 / 140,000.00 * 100 = 35.71428571%

If I wanted to keep consistent I would round that number up to 36 or cut it to 35. What would be the best approach to programming a method of calculating percentages that would give the user simple numbers. Would I use @left on the outcome or mathematical equations or ?

Thanks



  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Foster
Ex Member


Re: percentages
Reply #4 - Jul 15th, 2005 at 9:08pm
Print Post Print Post  
@ROUND (Page 210 of Sesame Programing Guide) looks like it would do the trick! Smiley
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: percentages
Reply #5 - Jul 15th, 2005 at 9:34pm
Print Post Print Post  
Quote:
@ROUND (Page 210 of Sesame Programing Guide) looks like it would do the trick! Smiley


What a creative approach, read the manual.   Grin

Thanks Foster I will give that a shot.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: percentages
Reply #6 - Jul 15th, 2005 at 10:48pm
Print Post Print Post  
Quote:
@ROUND (Page 210 of Sesame Programing Guide) looks like it would do the trick! Smiley


It seems to work well. Thanks again Foster.

Sometimes I get so caught up looking for the complicated solution (or at least thinking it will be complicated) that I miss the obvious.

This is a great reminder I need to read the manual once again. I have read it dozens of times but as I have been told,  you learn by repetition. (And with help from the forum)   
Smiley
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
NICEBERG
Full Member
Members
***
Offline


I came, I saw, I'm still
trying to figure it out!

Posts: 208
Location: Green Bay, WI
Joined: Dec 17th, 2003
Re: percentages
Reply #7 - Jul 16th, 2005 at 4:06pm
Print Post Print Post  
If Salary was formatted as money and
If Classamount was formatted as money and
Percent was formatted as number with 0 (or 1 or 2) decimal places then

Percent = (Salary / Classamount) * 100 works great too

No need to do the @tomoney or @round

« Last Edit: Jul 18th, 2005 at 2:13pm by NICEBERG »  
Back to top
 
IP Logged