Shop OBEX P1 Docs P2 Docs Learn Events
Rouding to whole numbers — Parallax Forums

Rouding to whole numbers

beckerwvbeckerwv Posts: 7
edited 2011-07-25 20:06 in Propeller 1
In SPIN, is there a simple way to round off a variable's decimal? I just want to have simple whole number to work with.

Thanks!!

Comments

  • Heater.Heater. Posts: 21,230
    edited 2011-07-25 19:11
    Welcome to the forum.
    There are only whole numbers in Spin. Everything is a signed integer. For example if you divide five by two you will get two.
    What exactly are you trying to do?
  • beckerwvbeckerwv Posts: 7
    edited 2011-07-25 19:35
    Thank you Heater - I think that may explain a lot of my issues..
    I was trying to test some trig functions, for example cos(111) should = -0.358... It kept returning 0, so I thought it was just a broken function.
    Based on what you are saying I will need to re-evaluate my algorithms - I am not sure yet if it will work without at least some decimal values.

    Thanks so much for your help!
  • Heater.Heater. Posts: 21,230
    edited 2011-07-25 20:06
    Except I was a bit wrong. You can use floating point values as constants in Spin or to initialize variables. But the operators +-*/ etc won't work properly with them.
    There is a very nice floating point package with all trig functions in the object exchange. Look for F32.
Sign In or Register to comment.