POV-Ray : Newsgroups : povray.unofficial.patches : Why & has higher precedence than + or - in isosurface functions? : Re: Why & has higher precedence than + or - in isosurface functions? Server Time
2 Sep 2024 06:12:24 EDT (-0400)
  Re: Why & has higher precedence than + or - in isosurface functions?  
From: Dick Balaska
Date: 6 Aug 2000 02:14:37
Message: <398D0212.8F73338E@buckosoft.com>
Warp wrote:
> 
> Dick Balaska <dic### [at] buckosoftcom> wrote:
> : I have also seen #define TRUE ~FALSE
> 
>   This is horrible. It doesn't work!
> 
>   Suppose we have:
> 
> #define FALSE 0
> #define TRUE ~FALSE
> 
>   Then TRUE will be -1 (ie. all bits set).
> 
>   Now suppose we want to add a "boolean" type:
> 
> typedef int BOOL;
> 
>   This will NOT work as it should:
> 
> int x=2, y=2;
> BOOL b;
> 
> b = (x==y);
> 
> if(b == TRUE)
>   puts("Equal");
> else
>   puts("Different");
> 
>   This will print "Different" although x and y are equal.

You are a young pup.
And you are correct that this doesn't work on 2000 C compilers
because the (user) definition of TRUE doesn't match the system
definition.

But suppose you are working on a 6502 :) or a PDP-11, which can
deal with a -1 much easier than a 1; then it makes sense.
The PDP-11 is big-endian, so when you truncate a 1, you get 0
like down casting from int to word to char.  The -1 always stayed
consistent across casts.

dik


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.