Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Float32Full — Parallax Forums

Problem with Float32Full

marclamarcla Posts: 19
edited 2008-10-19 08:25 in Propeller 1
Hello!

When i run this program:
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

OBJ
  text     : "vga_text"
  Math     : "Float32Full"
  Floatstr : "FloatString"
Pub Main
Math.start
text.start(16)
Floatstr.SetPositiveChr(" ")
text.str(string("ACos(0,2)= "))
text.str(Floatstr.FloatToString(Math.ACos(0.2)))

I get "ACos(0,2)= 1.369439"
But isn't Acos(0,2) = 78.46304097?
What am·I doing wrong?

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2008-10-18 21:52
    1.369439 is in radians which does equal 78.46 degrees
    use text.str(Floatstr.FloatToString(Math.Degrees(Math.ACos(0.2))))

    I didn't check the documentation, it may be Math.FDegrees

    John Abshier
  • mirrormirror Posts: 322
    edited 2008-10-18 21:59
    The resuls is in radians, not degrees.
    There are 2 * pi radians in a circle, the equivalent to 360 degrees.

    and 1.3694 * 360 / ( 2 * pi) = 78.46.

    I think the library you mention already has funcitons for converting between radians and degrees.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • marclamarcla Posts: 19
    edited 2008-10-19 08:25
    Thanks!
Sign In or Register to comment.