Shop OBEX P1 Docs P2 Docs Learn Events
QDIV overflow behaviour — Parallax Forums

QDIV overflow behaviour

It appears that QDIV/QFRAC give odd results in overflowing cases.

              setq ##$0100_0000
              qdiv ##$0000_0000,##$0000_0100
              getqx pa
              debug(uhex_long(pa))

gives

Cog0  pa = $FF00_00FF

I'm too tired right now to figure out the full pattern to this, but try moving the bits around and see how the values change. It seems (?) that all overflow results are larger than $8000_0000 (If you can find a division that breaks that assumption, please post it)

I noticed this while trying to figure out how I want to do clipping for my 3D project. If the above theory can be relied on, that'd allow for an interesting shortcut (check side clipping planes by result of perspective divide rather than separately before)

Sign In or Register to comment.