POV-Ray : Newsgroups : povray.general : Re: Probably been asked... Why no power operator? Server Time
5 Aug 2024 10:19:57 EDT (-0400)
  Re: Probably been asked... Why no power operator? (Message 11 to 20 of 37)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Warp
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 13:57:12
Message: <3dd3f208@news.povray.org>
AC <amb### [at] teliacom> wrote:
> I don't think it would hurt to ask a math teachers (Highschool, Collage or
> University)

  One problem is that in math there's no power operator, so there is no
operator precedence in the same sense. Only in computer languages there
is a power operator.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Jellby
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 15:05:26
Message: <3dd40205@news.povray.org>
> I am of the opinion that sacrificing the strange 2^-3 syntax for 2^(-3)
> makes more sense than having to use -(3^9) in place of -3^9. This is
> *sorta* inconsistent with the way the * operator works, except that no
> one's going to argue what the value of -2*2 is.

Wouldn't it be possible to have *both* 3^-2 and -3^2 generate an error, to 
force the use of parenthesis: 3^(-2) and either -(3^2) or (-3)^2? This 
would at least get rid of the need of pow (but not of the need of pov ;) ), 
while givin rise to no misunderstunding.

-- 

Linux User #289967 (counter.li.org)
PGP Pub Key ID: 0x01A95F99 (pgp.escomplinux.org)


Post a reply to this message

From: Warp
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 15:27:41
Message: <3dd4073d@news.povray.org>
Jellby <jel### [at] m-yahoocom> wrote:
> Wouldn't it be possible to have *both* 3^-2 and -3^2 generate an error

  That would be illogical.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Christopher James Huff
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 15:48:49
Message: <chrishuff-D16DE3.15481814112002@netplex.aussie.org>
In article <3dd33dfe$1@news.povray.org>,
 "Timothy R. Cook" <tim### [at] scifi-fantasycom> wrote:

> Your memory is faulty.  3.1g is the version that came before 3.5.

Not exactly. These were largely bug fix updates of the same version, 
3.1. On the Mac, I think they got up to 3.1g.r2. There may have been a 
3.1h, too, but none of the revisions added a power operator.


> *ducks, runs*

*Throws a handful of ball bearings (mirrored spheres) in Timothy's 
path...*

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 15:54:37
Message: <chrishuff-B70261.15540814112002@netplex.aussie.org>
In article <3dd3cb3c$1@news.povray.org>, "Slime" <slm### [at] slimelandcom> 
wrote:

> Well, to say there's no mathematical reason doesn't seem entirely correct.
> Most everyone is taught that exponentiation comes before negation in an
> early algebra class. It's the way we've been taught to think.

Um, no. In algebra, there is no precedence, the exponent is in 
superscript, so there is no ambiguity. A plain text programming language 
doesn't have this, an operator has to be used, so it has to pick a 
precedence. I don't know what you were taught...


> Besides, I would think that since we're adding ^ as a new operator, we could
> give it whatever precedence we wanted, and it just seems more logical to me
> to make it work the way we've been taught it should work than to allow the
> 2^-3 syntax just for convenience.

Not for convenience, for self consistency. There isn't an existing rule, 
so the one that was most logical and consistent was chosen.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 16:56:37
Message: <3dd41c15$3@news.povray.org>
How is this off-topic?

"Alan Kong" <ako### [at] povrayWWWSPAMCOMorg> wrote in message
news:5j16tu0p39v97731vch4fp6b24ouvkkpht@4ax.com...
> If a new discussion about this topic begins, kindly set
> followups to povray.off-topic, TIA.
>


Post a reply to this message

From: Timothy R  Cook
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:02:29
Message: <3dd41d75@news.povray.org>
Jellby wrote:
> Wouldn't it be possible to have *both* 3^-2 and -3^2 generate an error, to 
> force the use of parenthesis: 3^(-2) and either -(3^2) or (-3)^2? This 
> would at least get rid of the need of pow (but not of the need of pov ;) ), 
> while givin rise to no misunderstunding.

Doesn't 3^(-2) translate to sqrt(3)?

-- 
Tim Cook
http://empyrean.scifi-fantasy.com

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GFA dpu- s: a?-- C++(++++) U P? L E--- W++(+++)>$
N++ o? K- w(+) O? M-(--) V? PS+(+++) PE(--) Y(--)
PGP-(--) t* 5++>+++++ X+ R* tv+ b++(+++) DI
D++(---) G(++) e*>++ h+ !r--- !y--
------END GEEK CODE BLOCK------


Post a reply to this message

From: Jerry
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:07:54
Message: <jerry-0B1C72.14075314112002@netplex.aussie.org>
In article <3dd3f208@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:
>AC <amb### [at] teliacom> wrote:
>> I don't think it would hurt to ask a math teachers (Highschool, Collage or
>> University)
>
>  One problem is that in math there's no power operator, so there is no
>operator precedence in the same sense. Only in computer languages there
>is a power operator.

Well, not really. You use superscripting to indicate power outside of 
computer languages. The power operator is used because most computer 
languages are typed on terminals that have difficulty accepting 
superscripts. I'd hazard a guess that the 'hat' is used solely because 
it has the effect of 'pointing up', i.e., saying that the next number is 
superscripted.

In my opinion, the power operator should act exactly as superscripting 
does. If

  2
-3

(You will need to be viewing that in a non-proportional font)

is -9, then -3^2 should also be -9; if the above is 9, then -3^2 should 
also be 9.

I'm fairly certain, however, that I remember from algebra that the 
superscripted would result in -9. What is the answer to:

22-3^2

?

I'll note that in the few calculators I have that allow typing in 
freeform, they are split on -3^2:

MoreCalculator:
-3**2
result=-9

bc:
-3^2
9

bwbasic:
bwBASIC: print -3^2
 9

python:
>>> -3**2
-9

perl:
echo print '-3**2, "\n"' | perl
-9

But all of them give 13 as the answer to 22-3^2 :*)

Either solution would be better than throwing out the operator, however.

Jerry
-- 
http://www.hoboes.com/jerry/
"Give a man a fish and you feed him for a day. Teach him to fish, and you've
depleted the lake."--It Isn't Murder If They're Yankees
(http://www.hoboes.com/jerry/Murder/)


Post a reply to this message

From: Slime
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:14:34
Message: <3dd4204a$1@news.povray.org>
> Doesn't 3^(-2) translate to sqrt(3)?


No, you're thinking of 3^(1/2). 3^(-2) is the same as 1/(3^2) = 1/9.

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


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:19:51
Message: <3dd42187$3@news.povray.org>
"AC" <amb### [at] teliacom> wrote in message news:3dd3e7b2@news.povray.org...
>
> My vote would be on -3^2=9
>


The problem is that you're more likely to have   4^2-3^2.


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.