Shop OBEX P1 Docs P2 Docs Learn Events
Taking an integer to a floating point power — Parallax Forums

Taking an integer to a floating point power

nrk752nrk752 Posts: 8
edited 2006-06-06 17:47 in General Discussion
I am trying to calculate the result of this formula in a Javelin program:
y = 153.52 * x ^ -0.1775
where x is an integer.· In Float32Math it is possible to take a floating point number to an integer power, and to take e to a floating point power, but how would I go about taking an integer to a floating point power?· My only other solution at this point is to use a set of peicewise linear formulas that approximate the curve within limited regions. ·

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-06 15:52
    y = 153.52 * (x ^ -0.1775)

    x = e ^ z

    z = logE(x)

    y = 153.52 * (e ^ (-0.1775*z))

    regards peter
  • nrk752nrk752 Posts: 8
    edited 2006-06-06 16:33
    Ok, thanks, but how do I take the natural log of a float on a Javelin? I don't see a function for it.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-06-06 17:47
    x = e ^ z

    log10(x) = z*log10(e)

    z = log10(x)/log10(e)

    regards peter
Sign In or Register to comment.