|
![](/i/fill.gif) |
William F Pokorny <ano### [at] anonymous org> wrote:
> On 2/17/23 20:49, Tor Olav Kristensen wrote:
> >> Aside: You can use the 3 term select depending upon a boolean result in
> >> the first term test by doing something like:
> >>
> >> select(1-(2*((x<0.0) | (x>1.0))), 0, 1)
> >> ...
> > How about just this:
> >
> > select(
> > -((x < 0.0) | (1.0 < x)),
> > 0,
> > 1
> > )
> >
> > - or this:
> >
> > select(
> > -((0.0 <= x) & (x <= 1.0)),
> > 1,
> > 0
> > )
>
> :-)
>
> Very likely OK in practice, and cleaner in form than my three term select.
>
> What spooks me some is that -0 and +0 are real things in the IEEE
> floating point standard and as supported by C++. If a C++ coder has
> thought to test for -0 < 0, they can.
When you mention it, I think that I've actually have run into a problem with
negative zero in a version of POV-Ray.
IIRC I got different result when I used select() from what I got when I used <
or > in an #if statement.
So yes, it is scary.
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
![](/i/fill.gif) |