[retroforth] Re: 'not' not working correctly

  • From: Charles Childers <charles.childers@xxxxxxxxx>
  • To: retroforth@xxxxxxxxxxxxx
  • Date: Tue, 25 Jan 2005 06:12:07 -0500

After testing several Forths, only one doesn't return "-2" when I do
"1 not".  The only one that returns "0" is Win32Forth. I found the
following note on the web:

> Logical NOT
> NOT reverses the logical state of its operand. If the 
> operand is 0, 1 is returned, else 0 is returned.
>
>       !4      /* Returns 0    */
>       !-4     /* Returns 0    */
>       !1      /* Returns 0    */
>       !0      /* Returns 1    */

If this is accurate, not should basically be:  

  : not 0 =if 1 ;; then 0 ;

I'll probably keep the binary not in RetroForth 8, but define a
logical not as part of the code library.

-- 
Charles Childers
http://www.retroforth.org

Other related posts: