Author Topic: nasm treats negative numbers as non numbers!  (Read 12288 times)

nobody

  • Guest
nasm treats negative numbers as non numbers!
« on: February 21, 2005, 09:44:40 PM »
try doing this

%ifnnum -1
  %error "-1 is not a number."
%endif

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: nasm treats negative numbers as non numbers!
« Reply #1 on: February 22, 2005, 04:43:03 AM »
Yeah, Nasm's a little brain-dead on this issue - just looks to see if the *first* character's a decimal digit. The "workaround" is to use "0-1" - kinda ugly, but you get used to it :)

We may get that fixed... someday... it's easy to get used to, honest! (if it wasn't, I suppose it would have been fixed by now :)

Best,
Frank

nasm64developer

  • Guest
Re: nasm treats negative numbers as non numbers!
« Reply #2 on: February 22, 2005, 02:13:21 PM »
> Yeah, Nasm's a little brain-dead on this issue

No, it isn't. Instead the NASM preprocessor is
behaving as expected. The term "-1" consists of
two tokens, "-" and "1". And "-" isn't a number.

> We may get that fixed

Doing so would break the preprocessor's logic.
As well as backwards compatibility.

nobody

  • Guest
Re: nasm treats negative numbers as non numbers!
« Reply #3 on: March 04, 2005, 07:38:55 AM »
0y is also a number for nasm's preprocessor.
Very its preprocessor's logic is quite other than its assembler's logic.

%ifnum 0y
%error 0y is a number
%endif