POV-Ray : Newsgroups : povray.general : What is this strangeness? Server Time
4 Nov 2026 11:20:07 EST (-0500)
  What is this strangeness? (Message 1 to 5 of 5)  
From: kurtzlepirate
Subject: What is this strangeness?
Date: 3 Nov 2026 11:15:49
Message: <6aea08b5$1@news.povray.org>
Hello,

I spent some time trying to figure out why my code was producing bizarre 
results. It couldn't be simpler. It fits on a single line :

	#declare y0 = a*x0*+b;


Of course, there are no syntax errors.
A typo left an “*” after the x0.

What I don't understand is the calculation involving that extra “*”

With a = 0.51, b = 10.66 and  x0 =  -16.25, the correct calculation 
yields 2.37 and with the extar "*", -88.34 !

Where's the logic? I haven't been able to find a connection between the 
two values, so I don't understand what operation this * performs.



I'm sure the people here have already figured it out and will be able to 
explain it to me. Thanks


-- 
klp
compagnie de la banquise


Post a reply to this message

From: Leroy
Subject: Re: What is this strangeness?
Date: 3 Nov 2026 12:40:00
Message: <web.6aea1c252c634b29d2f83f61f712fc00@news.povray.org>
kurtzlepirate <kur### [at] freefr> wrote:
> Hello,
>
> I spent some time trying to figure out why my code was producing bizarre
> results. It couldn't be simpler. It fits on a single line :
>
>  #declare y0 = a*x0*+b;
>
>
> Of course, there are no syntax errors.
> A typo left an “*” after the x0.
>
> What I don't understand is the calculation involving that extra “*”
>
> With a = 0.51, b = 10.66 and  x0 =  -16.25, the correct calculation
> yields 2.37 and with the extar "*", -88.34 !
>
> Where's the logic? I haven't been able to find a connection between the
> two values, so I don't understand what operation this * performs.
>
>
>
> I'm sure the people here have already figured it out and will be able to
> explain it to me. Thanks
>
>
> --
> klp
> compagnie de la banquise

It seen POV's parser just ignores the plus in your equation

 a*x0*+b becomes a*x0*b which is -88.34

drop the * and you get a*x0+b which is the 2.37

Try #declare y0 = a*x0*-b; and you'll get 88.34

Try #declare y0 = a*x0+*b; and you'll an Parser Error

Some parsers can't handle the '*+' syntax and crash. It has happen to me But I
can't remember when or where:)

Have Fun!


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: What is this strangeness?
Date: 3 Nov 2026 12:50:00
Message: <web.6aea1e472c634b2975a02fd89db30a9@news.povray.org>
kurtzlepirate <kur### [at] freefr> wrote:
> Hello,
>
> I spent some time trying to figure out why my code was producing bizarre
> results. It couldn't be simpler. It fits on a single line :
>
>  #declare y0 = a*x0*+b;
>
>
> Of course, there are no syntax errors.
> A typo left an “*” after the x0.
>
> What I don't understand is the calculation involving that extra “*”
>
> With a = 0.51, b = 10.66 and  x0 =  -16.25, the correct calculation
> yields 2.37 and with the extar "*", -88.34 !
>
> Where's the logic? I haven't been able to find a connection between the
> two values, so I don't understand what operation this * performs.
>
>
>
> I'm sure the people here have already figured it out and will be able to
> explain it to me. Thanks

It is just one more multiplication. The last plus sign is here the unary plus
operator. The unary minus operator negates the operand, the unary plus operator
does not.

This is a valid expression:  2 * -3 = -6

- and so is this:  2 * +3 = +6 = 6

https://www.geeksforgeeks.org/c/unary-operators-cc/#unary-plus

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Leroy
Subject: Re: What is this strangeness?
Date: 3 Nov 2026 13:05:00
Message: <web.6aea21172c634b29ac7cd2e9f712fc00@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
> kurtzlepirate <kur### [at] freefr> wrote:
> > Hello,
> >
> > I spent some time trying to figure out why my code was producing bizarre
> > results. It couldn't be simpler. It fits on a single line :
> >
> >  #declare y0 = a*x0*+b;
> >
> >
> > Of course, there are no syntax errors.
> > A typo left an �*� after the x0.
> >
> > What I don't understand is the calculation involving that extra �*�
> >
> > With a = 0.51, b = 10.66 and  x0 =  -16.25, the correct calculation
> > yields 2.37 and with the extar "*", -88.34 !
> >
> > Where's the logic? I haven't been able to find a connection between the
> > two values, so I don't understand what operation this * performs.
> >
> >
> >
> > I'm sure the people here have already figured it out and will be able to
> > explain it to me. Thanks
> >
> >
> > --
> > klp
> > compagnie de la banquise
>
> It seen POV's parser just ignores the plus in your equation
>
>  a*x0*+b becomes a*x0*b which is -88.34
>
> drop the * and you get a*x0+b which is the 2.37
>
> Try #declare y0 = a*x0*-b; and you'll get 88.34
>
> Try #declare y0 = a*x0+*b; and you'll an Parser Error
>
> Some parsers can't handle the '*+' syntax and crash. It has happen to me But I
> can't remember when or where:)
>
> Have Fun!
I couldn't let it go. I had to try something.

 #declare y0 = a*x0*+++++++++++b; & #declare y0 = a*x0*-----------b;

Both work, kind of :}


Post a reply to this message

From: kurtzlepirate
Subject: Re: What is this strangeness?
Date: 4 Nov 2026 06:27:22
Message: <6aeb169a$1@news.povray.org>
Hello,


That's exactly right.
In fact, the code is interpreted as #declare y0 = a * x0 * (+b);
That makes perfect sense.

Another problem with understanding the mechanism is that i used the 
actual values from my code. If i use simpler values, it becomes much 
clearer right away. First, with a = 1, we eliminate one parameter; then, 
with b = 2 and x0 = 3, we get y0 = 3 + 2 = 5 vs y0 = 3 * 2 = 6.




Tor, Leroy, thank you both very much for your suggestions.



-- 
klp
compagnie de la banquise


Post a reply to this message

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