|
|
|
|
|
|
| |
| |
|
|
From: Jörg 'Yadgar' Bleimann
Subject: Nested #switch...#end blocks - strange behaviour!
Date: 15 May 2006 18:55:49
Message: <446906f5$1@news.povray.org>
|
|
|
| |
| |
|
|
High!
To differentiate multiple camera views according to the clock variable,
I set up a logical structure consisting of nested #switch...#end blocks
- only two levels deep, but a strange effect always occurred: when the
inner #switch block is reached, only either the first or the last
alternative is chosen, but not the ones in between. With this test
script, this means if I start with +k1.1 or +k1.2, I always only got
"One point ????" as #warning output... and, strangely, obviously line 2
is interpreted correctly (see output in line 4)! Is this a bug actually?
#declare clock1 = int(clock);
#declare clock2 = mod(clock*10, 10);
#warning concat("clock2 = ", str(clock2, 1, 0))
#switch(clock1)
#case (0)
#warning "Zero!"
#break
#case (1)
#switch(clock2)
#case (0)
#warning "One point zero!"
#break
#case (1)
#warning "One point one!"
#break
#case (2)
#warning "One point two!"
#break
#else
#warning "One point ????"
#end
#break
#case (2)
#warning "Two!"
#break
#case (3)
#warning "Three!"
#break
#else
#warning "Oops..."
#end
See you in Khyberspace!
Yadgar
Post a reply to this message
|
|
| |
| |
|
|
From: Bob H
Subject: Re: Nested #switch...#end blocks - strange behaviour!
Date: 15 May 2006 19:22:51
Message: <44690d4b@news.povray.org>
|
|
|
| |
| |
|
|
Curious thing... apparently it's the mod() doing it because when I replaced
that part with #declare clock2=1; it works (likewise if clock2=2). And I
haven't a clue why it would happen like that.
Post a reply to this message
|
|
| |
| |
|
|
From: Chris B
Subject: Re: Nested #switch...#end blocks - strange behaviour!
Date: 15 May 2006 20:01:26
Message: <44691656$1@news.povray.org>
|
|
|
| |
| |
|
|
"Bob H" <omniverse@charter%net> wrote in message
news:44690d4b@news.povray.org...
> Curious thing... apparently it's the mod() doing it because when I
> replaced that part with #declare clock2=1; it works (likewise if
> clock2=2). And I haven't a clue why it would happen like that.
>
Hi Bob,
I think it's just the usual rounding errors. If you use the integer part of
the result it works:
int(mod(clock*10,10))
The cause didn't show up when you used
#warning concat("clock2 = ", str(clock2, 1, 0))
because this specifies 0 decimal places.
It shows up if you do str(clock2, 1, 30)
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
From: Bob H
Subject: Re: Nested #switch...#end blocks - strange behaviour!
Date: 15 May 2006 20:13:05
Message: <44691911@news.povray.org>
|
|
|
| |
| |
|
|
"Chris B" <c_b### [at] btconnectcomnospam> wrote in message
news:44691656$1@news.povray.org...
>
> The cause didn't show up when you used
> #warning concat("clock2 = ", str(clock2, 1, 0))
> because this specifies 0 decimal places.
> It shows up if you do str(clock2, 1, 30)
Wups. Yep, didn't think to look for decimal places.
Post a reply to this message
|
|
| |
| |
|
|
From: John VanSickle
Subject: Re: Nested #switch...#end blocks - strange behaviour!
Date: 15 May 2006 22:40:35
Message: <44693ba3$1@news.povray.org>
|
|
|
| |
| |
|
|
> High!
>
> To differentiate multiple camera views according to the clock variable,
> I set up a logical structure consisting of nested #switch...#end blocks
> - only two levels deep, but a strange effect always occurred: when the
> inner #switch block is reached, only either the first or the last
> alternative is chosen, but not the ones in between. With this test
> script, this means if I start with +k1.1 or +k1.2, I always only got
> "One point ????" as #warning output... and, strangely, obviously line 2
> is interpreted correctly (see output in line 4)! Is this a bug actually?
It could be floating point round-off error. If you absolutely,
positively expect it to be an integer, you really need to put floor()
around any fraction multiplied by anything else.
Regards,
John
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|