Shop OBEX P1 Docs P2 Docs Learn Events
float32full again!!!!!!!!! — Parallax Forums

float32full again!!!!!!!!!

pilot00pilot00 Posts: 30
edited 2009-04-14 01:08 in Propeller 1
I have been trying to use this application to get sine and cosine values by using a simple object
prior to integrating it into my project.
Sorry I do not have winzip working so I cannot bundle it al together but if someone has worked with
this before can you help.

I was able to get the attached code to work but I get eroneous numbers.

I made it simple so I can check the values on my calculator.

Thanks

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-04-14 01:05
    This line: alpha:=20
    makes alpha in integer. You then use it as a floating point argument to the tan function. Change 20 to 20.0 to force alpha to be a float. Number and numbera are floats. You are using them as arguments to the dec method which expects an integer. You could use the floatstring object to convert number and numbera to something to print or use another method to the floating point variables to something that can print.

    John Abshier
  • Zap-oZap-o Posts: 452
    edited 2009-04-14 01:08
    I dont think it is working because you can not send to the serial port a floating point number with that line of code.

    Try using the float to string object.
    [b]
    
    obj
     debug:"fullduplexserialplus"
     math:"float32full"
     flt :"floatToString"
     
    pub mathtest|alpha, number,numbera
     math.start
     debug.start(31,30,0,9600)
      alpha:=20
      waitcnt(clkfreq*2+cnt)
      repeat
      
        number:=math.tan(alpha)
        debug.str(flt.floattostring(number))
        debug.tx(9)
        debug.tx(13)
         
        numbera:=math.log(alpha)
        debug.tx(9)
        debug.tx(13)
        debug.dec(numbera)
       waitcnt(clkfreq+cnt)
    
    [/b]
    
    

    Post Edited (Zap-o) : 4/14/2009 1:13:29 AM GMT
Sign In or Register to comment.