dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Not-a-Number

  1. #1
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    Why is this, is it some kind of big:

    a=Math.pow(0,2);

    in publish: a=NaN
    -----------------------------
    but if i put it like this:

    a=0 * 0

    in publish: a=0
    -----------------------------
    and i really need the power 2 operation

    Any suggestions?

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    there are two ways to calculate power(a, b) - one by actually multiplying a b times (provided b is an integer) or by calculating Math.exp(b * Math.ln(a))
    The error shows that flash uses second method...
    If you just need power 2, why not make your own function
    function pow2(a) { return a*a; }
    Unlike the builtin one it even produces correct results on negative numbers

    Musicman

  3. #3
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    Really heavyweight

    Thanks, i though to use Flash's internal commands, but looks like i will have to make it this way, thanks bro.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center