POV-Ray : Newsgroups : povray.newusers : What does '#if (0<M<360)' mean? Server Time
26 Dec 2024 10:25:33 EST (-0500)
  What does '#if (0<M<360)' mean? (Message 1 to 4 of 4)  
From: Günther Dietrich
Subject: What does '#if (0<M<360)' mean?
Date: 4 Feb 2007 03:45:08
Message: <muhg94-r6q.ln1@520042650687.t-online.de>
Hi,

in sunpos.inc, I find several statements of this form:

|#if (0<M<360)
|    ...
|#end

I can remember, that -- many years ago -- I read somewhere about this 
'(value1 < variable < value2)' construct. But I cannot recall, what the 
construct does.
In the POV-Ray documentation, I could not find an explanation of this 
construct. If it is there, the explanation seems to be hidden very 
thoroughly. :)

Could anyone please tell me, what '(0<M<360)' does?



Many thanks in advance,



Post a reply to this message

From: Warp
Subject: Re: What does '#if (0<M<360)' mean?
Date: 4 Feb 2007 03:52:31
Message: <45c59ecf@news.povray.org>

> Could anyone please tell me, what '(0<M<360)' does?

  I actually don't remember if the < operator has a left-to-right or
a right-to-left precedence, but in any case it means either:

  - Calculate the "0<M" comparison, returning 0 or 1, and then compare
    that result to 360, which always gives true, or

  - Calculate the "M<360" comparison, returning 0 or 1, and then compare
    that result to 0, which means that the expression is completely
    equivalent to #if(M<360) (ie. the "0<" part does nothing)

  In any case, it's a clear programming mistake. What the author probably
wanted to do is:

#if (0<M & M<360)

-- 
                                                          - Warp


Post a reply to this message

From: Günther Dietrich
Subject: Re: What does '#if (0<M<360)' mean?
Date: 4 Feb 2007 08:05:12
Message: <ul1h94-9kq.ln1@520042650687.t-online.de>
Warp <war### [at] tagpovrayorg> wrote:

>  In any case, it's a clear programming mistake. What the author probably
>wanted to do is:
>
>#if (0<M & M<360)

That was also one of my ideas. But -- maybe I'm wrong -- I have a faint 
memory of having read about such a construct a long time ago. Perhaps it 
was in a different context, not related to POV-Ray.



Thanks,



Post a reply to this message

From: Warp
Subject: Re: What does '#if (0<M<360)' mean?
Date: 4 Feb 2007 09:38:36
Message: <45c5efeb@news.povray.org>

> That was also one of my ideas. But -- maybe I'm wrong -- I have a faint 
> memory of having read about such a construct a long time ago. Perhaps it 
> was in a different context, not related to POV-Ray.

  Not related to POV-Ray.

  The closest thing POV-Ray has is the #range keyword (which is only
usable in #switch blocks, though).

-- 
                                                          - Warp


Post a reply to this message

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