Skip to main content
admin10
Participant
July 1, 2015
Question

ActionScript 3 Math - Need Help!

  • July 1, 2015
  • 2 replies
  • 615 views

Hello I am having difficult with ActionScript 3 Square Root Math!

The output for some odd reason is not correct. Could you please check my calculations.

Problematic Code A)

Counter is just a simple button to toggle the calculation of the square root. In the below numA.text is the input field where the user enters the number to be square rooted. The result is in then displayed in the output_txt field.

Problematic Code B)

In the below example the same applies except numA.text is the input field for the power of the square root. And numB.text is the square root number.

Thanks for the help.

This topic has been closed for replies.

2 replies

July 1, 2015

Does your "strnum" variable have a datatype declaration? If so, what is it? Number, int, or uint?

July 1, 2015

I think you need to change what is going on in your AS code if the output value is not what you expect. I performed the math in a calculator following the order of operations you have in code (taking the square root of 8 and raising 2 to the power of the previous result) and I get the exact same value of "8.000000000000002".

What value are you expecting it to output?

July 1, 2015

Just the square root of 8 is 2.82427125 so you may need to hit enter/equals one more time on the calculator to get the final result. 2 ^ sqrt(8) should equal 7.102993301316016. Also, for the Math.pow() method, the second parameter is power so you should flip your variables places in that call and you will get the correct value.

Ned Murphy
Legend
July 1, 2015

What about the output is not correct for each of the code examples?