• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Help! Coding for calculator


Junior Member
I need to put together a correctly functioning calculator swf for an educational site. I have used code from another calculator which works fine apart from the % button. Does anyone know the code which will allow the % button to work correctly?

Thanks in anticipation


Junior Member
I don't think I explained myself very well. The calculator has to have a correctly functioning % button. The current code for the % button I have is as follows:

on (release, keyPress "%") {
display = Number(display)*100;
operation_s = "%";

but I am told by my educational colleagues that does not work correctly and needs to work as the % button shown on this link:
Calculator - Metacalc

Can anybody help?


Senior Member
Yes and I explained I would do it using multiplication.

% buttons are used to divide or multiply by a given percentage.

To do that I would manually multiply or divide by the [given percentage / 100 ]

problem solved

if they want to do 100 * 50% its equivalent to 100 * 50/100 which is 50....

or 100 / 50% is equivalent to 100 / 50/100 which is 200


Junior Member
Thanks Renniks but as I said, I need to have a functioning % button as shown in the example, not an alternative way of working out percentages.

Anyone know the code?


Senior Member
oh my god, even I understand this!

THAT IS THE METHOD - the % sign needs to do the multiplication for you!!!!


Junior Member
Apologies if I'm slow here but code is hardly my forte. If you are referring to a method of code can someone interperate and tell me exactly what code to put in that is likely to make the % button work as it needs to. I have 8 different souce examples and am told that none of them work correctly. Thanks.


Senior Member
My understanding of it is that the % sign completes a mathematical equasion

example you have 20 on the screen and want to multiply by 10%

20 dividied by 100 (that makes 1%) = 0.2
0.2 then multiplied by 10 (because thats how many percents you want) = 2
Original number (20) multiplied (or added, or subtracted, or divided) by whatever the percentage was (2)
20 * 2 = Final number 40