Shop OBEX P1 Docs P2 Docs Learn Events
Floating point library routines hang when converting to integer — Parallax Forums

Floating point library routines hang when converting to integer

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2022-01-24 21:49 in PASM/Spin (P1)

I've discovered that the ftrunc and fround routines in Float32, Float32A, and Float32Full hang when the argument is out-of-bounds for an integer. Here's my test code:

CON

  _clkmode      = xtal1 + pll16x
  _xinfreq      = 5_000_000

OBJ

  ser:  "Parallax Serial Terminal"
  flt:  "Float32"

PUB start | fp_number

  fp_number := $dd4495b3

  ser.start(9600)

  ser.str(string("Start.", 13))
  ser.dec(flt.ftrunc(fp_number))
  ser.str(string(13,"Done."))

BTW, the Spin version, FloatMath, does okay: it just returns zero for arguments that are out-of-bounds.

-Phil

Comments

Sign In or Register to comment.