POV-Ray : Newsgroups : povray.unofficial.patches : Why & has higher precedence than + or - in isosurface functions? Server Time
2 Sep 2024 06:17:53 EDT (-0400)
  Why & has higher precedence than + or - in isosurface functions? (Message 22 to 31 of 41)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Warp
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 11:12:16
Message: <39883a4f@news.povray.org>
pk <thi### [at] videotronca> wrote:
: You've never made any programmation before, have you?

  I have been programming for about 10 years.

: In most programming languages, they assign a value to TRUE, and another
: to FALSE(in the case above, FALSE=0, and TRUE=NOT(FALSE) )
: In other languages, fe, C(for which i dont't really remember the
: standard), it's something like TRUE = -1 (binary 11111111) and FALSE
: would be 0(binary 00000000)...

  Nope. In C a true value is 1 (for example the result of the sentence a==b
is 1 if a is equal to b, else 0). When testing a conditional, any value
other than 0 is considered true, and 0 is considered false.

  In this context (0.5 AND -2.8) would be true because none of them is 0.
This, however, has no mathematical meaning whatsoever. It hasn't any meaning
in isosurface functions either (what would a 'true' or 'false' value mean
in a function, may I ask?).

: And, for your trivia, it depends: most languages will do logical
: operations bit by bit, but i suppose that others have a Boolean
: type(Java, fe i think), and will undercast it before doing the
: LOGICAL_AND

  The point is that the & operator in isosurface functions is not even close
to the logical AND-operator of programming languages.

: And, yes, doing Logical operations bit by bit can be useful, and anyway,
: you can just add a comparison operator before doing the boolean
: operation... 

  Firstly, there's no bitwise AND-operator anywhere in the povray language,
and secondly, the &-operator in isosurface functions is neither a logical
nor a bitwise AND-operator.
  It would make no sense in having a logical operator in a function anyways.
Which function is 'true' or 'false'? How do you draw the function { true } ?
  (No, I'm not talking about the povray keyword 'true' here.)

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Dick Balaska
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 11:51:38
Message: <39884355.DCB5F320@buckosoft.com>
Warp wrote:

>   Nope. In C a true value is 1 (for example the result of the sentence a==b
> is 1 if a is equal to b, else 0). When testing a conditional, any value
> other than 0 is considered true, and 0 is considered false.

Your definition is wrong, but your example is correct. :)

False is 0.  True is not false.
1 is a true value, as is 2, as is -1.

I have seen #define TRUE 1
I have also seen #define TRUE ~FALSE

dik


Post a reply to this message

From: pk
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 11:56:38
Message: <39884510.338B87F5@videotron.ca>
Whoa! sorry! 8)
Warp wrote:
>   Nope. In C a true value is 1 (for example the result of the sentence a==b
> is 1 if a is equal to b, else 0). When testing a conditional, any value
> other than 0 is considered true, and 0 is considered false.
Well, I said i wasn't sure... -1 and 0 must be for Basic, then... 
>   In this context (0.5 AND -2.8) would be true because none of them is 0.
> This, however, has no mathematical meaning whatsoever. It hasn't any meaning
> in isosurface functions either (what would a 'true' or 'false' value mean
> in a function, may I ask?).
TRUE and FALSE having been declared before as constants, TRUE and FLASE
will have values...
>   It would make no sense in having a logical operator in a function anyways.
> Which function is 'true' or 'false'? How do you draw the function { true } ?
>   (No, I'm not talking about the povray keyword 'true' here.)
What do you mean? Isosurfaces are booleans for me: at location <x, y,
z>, there's a point(true, or 1), or there isn't any(false or 0)... So,
you have a function that draw a plane, and another one that draws a
sphere...
You AND them... the result? a circle... You & them... the result? a
circle...
In theory, it might not be the same, but let's ask the person who did
the patch about it...

Anyway, it's getting pretty hot in this thread...

I'm sorry if i offended you by assuming you had no programming
background... it just sounded like you only saw it from the
mathematician pt of view...

Paul
--
AKA paul_virak_khuong at yahoo.com, pkhuong at deja.com, pkhuong at
crosswinds.net and pkhuong at technologist.com(list not complete)...


Post a reply to this message

From: Ron Parker
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 12:42:16
Message: <slrn8ogkht.8in.ron.parker@fwi.com>
On Wed, 02 Aug 2000 11:50:45 -0400, Dick Balaska wrote:
>Warp wrote:
>
>>   Nope. In C a true value is 1 (for example the result of the sentence a==b
>> is 1 if a is equal to b, else 0). When testing a conditional, any value
>> other than 0 is considered true, and 0 is considered false.
>
>Your definition is wrong, but your example is correct. :)
>
>False is 0.  True is not false.
>1 is a true value, as is 2, as is -1.
>
>I have seen #define TRUE 1
>I have also seen #define TRUE ~FALSE

I prefer #define TRUE (1==1) and #define FALSE (1==0)

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Ron Parker
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 12:53:12
Message: <slrn8ogl6d.8in.ron.parker@fwi.com>
On Wed, 02 Aug 2000 11:58:08 -0400, pk wrote:
>What do you mean? Isosurfaces are booleans for me: at location <x, y,
>z>, there's a point(true, or 1), or there isn't any(false or 0)... So,
>you have a function that draw a plane, and another one that draws a
>sphere...

More specifically, a point is either inside or outside the isosurface.

>You AND them... the result? a circle... You & them... the result? a
>circle...
>In theory, it might not be the same, but let's ask the person who did
>the patch about it...

Well, in the code, the function that performs that operation is called
"and," but it doesn't use a logical operator to do what it does (it uses
min or max)  Personally, I always think of intersection/union as and/or
anyway, preferring to use CS methods to decompose complex CSG operations.
They're pretty interchangeable at this level, but it's not a mistake
you'd want to make in a higher-level math or CS course.  

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 14:32:53
Message: <39886955@news.povray.org>
In article <39884355.DCB5F320@buckosoft.com> , Dick Balaska 
<dic### [at] buckosoftcom>  wrote:

>>   Nope. In C a true value is 1 (for example the result of the sentence a==b
>> is 1 if a is equal to b, else 0). When testing a conditional, any value
>> other than 0 is considered true, and 0 is considered false.
>
> Your definition is wrong, but your example is correct. :)
>
> False is 0.  True is not false.
> 1 is a true value, as is 2, as is -1.
>
> I have seen #define TRUE 1
> I have also seen #define TRUE ~FALSE

In C++ he would be nearly right :-)   Except that there is no definition of
the internal representation of the type "bool" which is left to the
compiler/platform (i.e. some RISC platforms like PowerPC have several
condition-code registers and instructions to work with them).

Only conversions from and to "bool" are defined in C++, and in case of the
conversion of bool to anything, true will be "1".


     Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Peter Popov
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 18:09:25
Message: <1s6hos89l9r0i1bigu46lb40e6bat72dlv@4ax.com>
On 2 Aug 2000 11:12:16 -0400, Warp <war### [at] tagpovrayorg> wrote:

>  Nope. In C a true value is 1 (for example the result of the sentence a==b
>is 1 if a is equal to b, else 0). When testing a conditional, any value
>other than 0 is considered true, and 0 is considered false.

Why am I thinking that this issue has not been standardised yet?
Because I am wrong again? :)

>  The point is that the & operator in isosurface functions is not even close
>to the logical AND-operator of programming languages.

Ah, so *that* is the point I've been missing all this time! 

Can I have a sign?


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] usanet
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Ken
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 18:15:22
Message: <39889BC2.288D3B69@pacbell.net>
Peter Popov wrote:

> Ah, so *that* is the point I've been missing all this time!
> 
> Can I have a sign?

Ron Popov, please give Peter Parker a sign.

-- 
Ken Tyler - 1400+ POV-Ray, Graphics, 3D Rendering, and Raytracing Links:
http://home.pacbell.net/tylereng/index.html http://www.povray.org/links/


Post a reply to this message

From: Ron Parker
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 2 Aug 2000 18:54:24
Message: <slrn8ohabq.8q3.ron.parker@fwi.com>
On Wed, 02 Aug 2000 15:08:02 -0700, Ken wrote:
>Ron Popov, please give Peter Parker a sign.

He has one.  It has that cool spider on it.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Mark Gordon
Subject: Re: Why & has higher precedence than + or - in isosurface functions?
Date: 3 Aug 2000 20:22:50
Message: <398A0D84.245410EE@mailbag.com>
pk wrote:

> In most programming languages, they assign a value to TRUE, and another
> to FALSE(in the case above, FALSE=0, and TRUE=NOT(FALSE) )
> In other languages, fe, C(for which i dont't really remember the
> standard), it's something like TRUE = -1 (binary 11111111) and FALSE
> would be 0(binary 00000000)...

And then there are the Unix shells...

$ true
$ echo $?
0
$ false
$ echo $?
1

Just to keep everyone confused. ;-)

-Mark Gordon


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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