Shop OBEX P1 Docs P2 Docs Learn Events
Spin has a float(), I could use an int() — Parallax Forums

Spin has a float(), I could use an int()

John AbshierJohn Abshier Posts: 1,116
edited 2009-02-07 05:36 in Propeller 1
·TICKS_PER_INCH = 36000 / (PI * WHEEL_DIAMETER)· does not work and gives an error of "Floating point not allowed in integer expression"

float(integer expression) casts the interger expression as a float.· It would be nice to be able to say

TICKS_PER_INCH = 36000 / int(PI * WHEEL_DIAMETER)

John Abshier

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-02-06 22:02
    Why not:

    TICKS_PER_INCH = 360_000_000 / (31416 * WHEEL_DIAMETER)

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-06 22:05
    Look in the manual. The functions you need are TRUNC and ROUND.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-02-06 23:25
    Thanks Mike, you have the answer. My mind locked-in, incorrectly, float() as a cast not a function. I think I will reread the manual, byte 0 to byte n (Is that cover to cover for PDFs?) on my flight to Australia later this month.

    John Abshier
  • rjo_rjo_ Posts: 1,825
    edited 2009-02-07 05:36
    If you are planning to read the entire manual, you should consider taking a Propeller driven plane... with frequent and lengthy connections.

    Sorry... sometimes I just don't have the capacity to resist...
Sign In or Register to comment.