Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ActionScript 3 Math - Need Help!

Explorer ,
Jul 01, 2015 Jul 01, 2015

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.

TOPICS
ActionScript
530
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2015 Jul 01, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2015 Jul 01, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2015 Jul 01, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 01, 2015 Jul 01, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 02, 2015 Jul 02, 2015
LATEST

Not to sure on making it negative. If you know for a fact that a specific part of the calculation should always be negative, you can add a minus sign in front of your number variable whenever you reference it to make it negative, i.e. "-scientnotB"

You probably need someone who didn't get C's in math throughout school for more advance math questions

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines