POV-Ray : Newsgroups : povray.beta-test : Small bug, asking for someone to check on latest RC Server Time
29 Jul 2024 14:18:17 EDT (-0400)
  Small bug, asking for someone to check on latest RC (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: Anders K 
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 14:32:55
Message: <3cf12a57$1@news.povray.org>
> It still writes '1.0', but this is intended behavior IIRC, the unary '-'
> has a higher precedence than the '^'.

This is silly, since for even n, (-x)^n = x^n (and for odd n the precedence
doesn't make a difference). So there's no reason you would ever want (-x)^n,
and to write -(x^n) you have to use parentheses. Also, in standard
mathematical notation, -x^n means -(x^n). IMO, unless there's some kind of
limitation in the parser that prevents unary operators from having lower
precedence than binary operators (or something similar), this should be
changed; the unary + and - operators should have the same precedence as the
binary ones.

Anders

--
light_source{6#local D=#macro B(E)#macro A(D)#declare E=(E-#declare
C=mod(E D);C)/D;C#end#while(E)#if(A(8)=7)#declare D=D+2.8;#else#if(
C>2)}torus{1..2clipped_by{box{-2y}}rotate<1 0C>*90translate<D+1A(2)
*2+1#else}cylinder{0(C-v=1).2translate<D+C*A(2)A(4)#end-2 13>finish
{specular 1}pigment{rgb x}#end#end#end-8;1B(445000298)B(519053970)B
(483402386)B(1445571258)B(77778740)B(541684549)B(42677491)B(70)}


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 17:51:35
Message: <3cf158e7@news.povray.org>
In article <3cf12a57$1@news.povray.org> , "Anders K." <and### [at] prostard2gcom>
wrote:

>> It still writes '1.0', but this is intended behavior IIRC, the unary '-'
>> has a higher precedence than the '^'.
>
> This is silly, since for even n, (-x)^n = x^n (and for odd n the precedence
> doesn't make a difference). So there's no reason you would ever want (-x)^n,
> and to write -(x^n) you have to use parentheses. Also, in standard
> mathematical notation, -x^n means -(x^n). IMO, unless there's some kind of
> limitation in the parser that prevents unary operators from having lower
> precedence than binary operators (or something similar), this should be
> changed; the unary + and - operators should have the same precedence as the
> binary ones.

It works as it should and exactly like in all other programming languages
where the unary operators also have higher precedence than all other
operators.  It not only always worked this way in POV-Ray, it is also not a
bug and it will not be changed.

However, more to the point, unary operators have to have higher precedence
than all other operators or expressions turn out unreadable.  Imagine an
expression like (x+++---y) or (x*-y).  If the unary operator had lower
precedence they would be illegal, or at least it would make reading the
expressions much more difficult for a human *and* a computer...

As for the "mathematical notation" argument, the proper interpretation I have
always and everywhere been taught is to place parenthesis around the
statement.  I suppose the question if sign precedence is higher or lower than
the power in such a case seems to be a matter of opinion or common agreements
in certain groups rather than any standard.


    Thorsten


Post a reply to this message

From: Slime
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 22:03:32
Message: <3cf193f4@news.povray.org>
> However, more to the point, unary operators have to have higher precedence
> than all other operators or expressions turn out unreadable.  Imagine an
> expression like (x+++---y) or (x*-y).  If the unary operator had lower
> precedence they would be illegal, or at least it would make reading the
> expressions much more difficult for a human *and* a computer...

Ah. I never really understood why expressions like that worked =)

But that's ok, I didn't know it was the intended behavior...

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: N Shomber
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 23:53:00
Message: <3cf1ad9c@news.povray.org>
> As for the "mathematical notation" argument, the proper interpretation I
have
> always and everywhere been taught is to place parenthesis around the
> statement.  I suppose the question if sign precedence is higher or lower
than
> the power in such a case seems to be a matter of opinion or common
agreements
> in certain groups rather than any standard.

Sorry about the talk-down language in the website, but I strongly believe
that the notational standard is that -2^2=-4 while (-2)^2=4.

http://mathforum.org/library/drmath/view/57375.html

N Shomber


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 27 May 2002 03:40:45
Message: <3cf1e2fd@news.povray.org>
In article <3cf1ad9c@news.povray.org> , "N Shomber" <nsh### [at] hotmailcom>
wrote:

> Sorry about the talk-down language in the website, but I strongly believe
> that the notational standard is that -2^2=-4 while (-2)^2=4.
>
> http://mathforum.org/library/drmath/view/57375.html

Well, some website claiming something to be a standard doesn't really make it
one.  Anyway, my statement was not meant as an argument but as an observation.

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Wolfgang Thaller
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 28 May 2002 18:09:56
Message: <3cf40034@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote:
> It works as it should and exactly like in all other programming languages
> where the unary operators also have higher precedence than all other
> operators.

Let me give a few counter examples:

Mathematica, Matlab, Haskell, my TI-92+ calculator. I don't currently have
access to any other programming languages that support a power operator.

> [..] Imagine an
> expression like (x+++---y) or (x*-y).  If the unary operator had lower
> precedence they would be illegal, or at least it would make reading the
> expressions much more difficult for a human *and* a computer...

If the first expression was actually legal, then both expressions would
still be legal and have the same meaning, as there is no ambiguity involved.
Those beautiful C expressions are not the point however - we're only talking
about ^ and unary -, all other precedences should stay the same.

> As for the "mathematical notation" argument, [...] common agreements
> in certain groups rather than any standard.

At least where superscript notation for power can be used, no parantheses
are needed, and power has higher precedence than negation. That's
international standard. I'm absolutely sure. I swear. As for notation using
^, I think that should be the same by analogy.

One additional argument: I really think that
5 - x^2
should be the same as
- x^2 + 5

That's what we learned at school, that's what those studied mathematicians
that teach at my university are telling me, and that's what I would be
expecting when I'm writing a POV scene.

Unary minus should have the about same precedence as binary minus, IMHO.
Any deviation from this "mathematical standard" (IMHO) without producing at
least a warning message of some kind *could* be considered a "small bug" in
pov-ray.

Cheers,

Wolfgang Thaller


Post a reply to this message

From: Josh Seagoe
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 28 May 2002 23:46:55
Message: <3CF451DD.5060806@smileyface.com>
Wolfgang Thaller wrote:
> "Thorsten Froehlich" <tho### [at] trfde> wrote:
> 
>>It works as it should and exactly like in all other programming languages
>>where the unary operators also have higher precedence than all other
>>operators.
> Let me give a few counter examples:
> 
> Mathematica, Matlab, Haskell, my TI-92+ calculator. I don't currently have
> access to any other programming languages that support a power operator.

MS QBasic, anchient copy of Derive, TI-86 calculator
(tho the last two are a bit predictable, considering that a TI-92 
probably uses a newer version of Derive)

I don't know of a single language that has exponentation with a lower 
precedence than unary minus.

> If the first expression was actually legal, then both expressions would

x+++---y is legal: (x++)+(-(--y))

> Unary minus should have the about same precedence as binary minus, IMHO.
> Any deviation from this "mathematical standard" (IMHO) without producing at
> least a warning message of some kind *could* be considered a "small bug" in
> pov-ray.

Unary minus should have the same precedence as it has in C: higher than 
multiplication, but lower than some binary operators.  (::, ->, ., and, 
if C had it, exponentation)

But this is insanely easy to work around, so it's not very important.

-josh


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 29 May 2002 03:04:12
Message: <3cf47d6c@news.povray.org>
In article <3cf40034@news.povray.org> , "Wolfgang Thaller" 
<wol### [at] gmxnet> wrote:

> Unary minus should have the about same precedence as binary minus, IMHO.

Which would render (x*-y) illegal, of course...

Anyway, I am not going to get into any further discussion about this as I have
better things to do with my time.

    Thorsten

____________________________________________________
Thorsten Froehlich
e-mail: mac### [at] povrayorg

I am a member of the POV-Ray Team.
Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Wolfgang Thaller
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 29 May 2002 04:07:27
Message: <3cf48c3f$1@news.povray.org>
"Josh Seagoe" <jos### [at] smileyfacecom> wrote:

> x+++---y is legal: (x++)+(-(--y))
It isn't: (x++)+(--(-y))  // that's what my compilers say, they could be
wrong :-)

> But this is insanely easy to work around, so it's not very important.

It's insanely easy to work around _if_ you know it. It's insanely difficult
to spot if you are expecting standard behaviour and don't know where the bug
is.

Cheers,

Wolfgang Thaller


Post a reply to this message

From: Wolfgang Thaller
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 29 May 2002 04:51:35
Message: <3cf49697@news.povray.org>
> Which would render (x*-y) illegal, of course...

Not necessarily. Depends on implementation.

As the ^-operator is a new feature (it's _not_ in 3.1, so it has _not_
always worked this way in POV-Ray), I would strongly hope that this is fixed
before the final release (that is before people start relying on strange
behaviour).

I've taken a look at express.c from the 3.1 source code.
I don't know where exactly the ^-operator has been added, but I see that
it's not to easy, but definitely possible, to implement cleanly. A new
function will probably have to be added in order to give unary - just
slightly lower precedence than exponentiation.
If this is not fixed by the release for 3.1, a warning should be placed in
the manual
(by the way: the ^-operator seems to be missing from the manual). People
should be told not to rely on this, so that it can be changed if the parser
is rewritten one day. It would be a pity for the PovRay SDL to be "locked"
in to some non-standard behaviour.

Cheers,

Wolfgang Thaller


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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