# percentages in mx - Macromedia Director Basics

im using director mx at college and part of my course requires a percentage to be calculated from the value of two variables however, the script im using doesn't appear to work as im getting silly values. i've already set the float precision if you think that's what it is... heres an example of the code i'm using gPercentage = ("gCorrect/gOverall") * 100 any help to remedy the problem woyuld be much appreciated.... moggie...

1. ## percentages in mx

im using director mx at college and part of my course requires a percentage to be calculated from the value of two variables however, the script im using doesn't appear to work as im getting silly values.
i've already set the float precision if you think that's what it is...

heres an example of the code i'm using

gPercentage = ("gCorrect/gOverall") * 100

any help to remedy the problem woyuld be much appreciated....

moggie

Moggie webforumsuser@macromedia.com Guest

2. ## Re: percentages in mx

not sure what value you're using, but you probably want to force it to
calculate with floating point values and also drop the quotes

gPercentage = (float(gCorrect)/float(gOverall)) * 100

give that a try,

regards,

richie

On Tue, 13 Jan 2004 11:50:57 +0000 (UTC), "Moggie"
[email]webforumsusermacromedia.com[/email] wrote:
>im using director mx at college and part of my course requires a percentage to be calculated from the value of two variables however, the script im using doesn't appear to work as im getting silly values.
>i've already set the float precision if you think that's what it is...
>
>heres an example of the code i'm using
>
>
>
> gPercentage = ("gCorrect/gOverall") * 100
>
>
>any help to remedy the problem woyuld be much appreciated....
>
>
>
>moggie
>
Richie Bisset Guest

3. ## Re: percentages in mx

You cannot multiply a string by a number...

gPercentage = (gCorrect / gOverall) * 100

and you might want to use floats as well:

gPercentage = (float(gCorrect) / gOverall) * 100

PS - only one number needs to be a float for the entire operation to be
float...

--

Dave
[url]http://www.blurredistinction.com/director[/url]

Dave Mennenoh Guest

#### Posting Permissions

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