Shop OBEX P1 Docs P2 Docs Learn Events
Exp10 function in spin — Parallax Forums

Exp10 function in spin

Paul MPaul M Posts: 95
edited 2009-07-01 13:22 in Propeller 1
Does anyone have the EXp10 function coded in spin?
I have no cogs left so I can't use the FloatMath functions.

Paul

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-07-01 12:56
    If you don't use FloatMath, is the result you need a float? Do you expect negative exponents?
  • Paul MPaul M Posts: 95
    edited 2009-07-01 13:11
    Sorry, my error - I am using FloatMath but it does not have an EXP10 function. Float32, Float32A etc have the function but are written in assembler and need a cog to run.
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-07-01 13:22
    var

    ten_exp long 10.0 & %0111111110000000000000000000000
    ten_mant long 10.0 & %0000000001111111111111111111111

    pub exp10( exp )
    return (ten_exp+%0111111110000000000000000000000 & (exp<<22)) & %0111111110000000000000000000000 + ten_mant

    quick and dirty because it does not check for overflow. So, as long as you don't deal with to big exponents.

    *Note: this is theory ... let's see if it works in practice ;o) *
Sign In or Register to comment.