Shop OBEX P1 Docs P2 Docs Learn Events
fastspin CASE — Parallax Forums

fastspin CASE

Is CASE different in fastspin compared to P1 spin? I just tried to compile the FloatString library. It's plain spin so I thought it should also work on the P2. However,
  case exponent
    'in range left of decimal
    11..0:
      AddDigits(exponent + 1)
    'in range right of decimal
    -1..digits - 13:
      zeros := -exponent
      AddDigits(1)
    'out of range, do scientific notation
    other:
      DoScientific
always falls through to the "other" case no matter what the value of "exponent" is.

If I replace it by
  if exponent => 0 AND exponent < 12
      AddDigits(exponent + 1)
  elseif exponent < digits-13
      DoScientific
  else
      zeros := -exponent
      AddDigits(1)
it works as expected. Maybe the compiler has a problem with the left bound of "11..0" and "-1..digits-13" being higher than the right bound. I think it should throw an error if it can't cope with it.

Comments

  • It's a bug; it's supposed to handle "11..0" the same as "0..11" but due to a typo in some code changes I made a while back it doesn't. This will be fixed in 4.1.2 (it's already fixed in github).
  • Total abuse of the language but still a bug.
Sign In or Register to comment.