POV-Ray : Newsgroups : povray.beta-test : Small bug, asking for someone to check on latest RC Server Time
29 Jul 2024 12:18:58 EDT (-0400)
  Small bug, asking for someone to check on latest RC (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Slime
Subject: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 12:45:23
Message: <3cf11123@news.povray.org>
I discovered this bug, but I'm still using RC3 (since i got home from
college and am back to a modem), so I can't really say "ooh a bug". So I'm
going to throw this out there, because it's really simple, and it'd be cool
if someone with the latest RC could quickly cut and paste this into a new
file and test if it's still there. It's one line, it'll take five seconds if
you're up to it.

The following code:
#debug str(-1^2,5,5)

outputs "1.00000". No negative sign. The negation operator is taking
precedence over the exponent operator. This shouldn't be the case. Note that
the same problem happens with -(1)^2, but not with -(1^2).

Mathematically, if I wrote -1^2, you'd think, "oh, one squared is one, and
then make it negative." But POV-Ray is apparently doing it in the wrong
order, saying "negative one squared is positive one." (-1)^2 works as
expected.

0-1^2 works as it should and outputs -1.00000, with the negative sign. It's
only a problem if the negation is the first part of the expression.

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


Post a reply to this message

From: Christoph Hormann
Subject: Re: Small bug, asking for someone to check on latest RC
Date: 26 May 2002 12:58:21
Message: <3CF1142D.E3470A0A@gmx.de>
Slime wrote:
> 
> [...]
> 
> The following code:
> #debug str(-1^2,5,5)
> 
> outputs "1.00000". No negative sign. The negation operator is taking
> precedence over the exponent operator. This shouldn't be the case. Note that
> the same problem happens with -(1)^2, but not with -(1^2).
> 

It still writes '1.0', but this is intended behavior IIRC, the unary '-'
has a higher precedence than the '^'. 

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 05 May. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

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

Goto Latest 10 Messages Next 2 Messages >>>

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