Re: two new motions
Juergen, P1788,
For completeness, should we also include nint (round to nearset integer) and
trunc (round to integer closest to zero)? While floor and ceil correspond to
IEEE 754 round to negative and positive infinity, respectively, nint and
trunc would correspond to IEEE 754 round to nearest and round to zero.
There are a few variants of these basic rounding functions that might be
worth considering, too. The function odd(x) returns 1 if floor(x) is odd, 0
otheriwse. The result is a square wave, which is a basic building block in
pattern and/or signal generation. Same for step(x) which is defined 0 if x <
0 else 1. The function repeat(x)=x-floor(x) is a sawtooth wave (another
important signal generator) with variants repeat1(x)=x-nint(x) and
fraction(x)=x-trunc(x).
Also, clamp(x)=max(0,min(x,1)) and clamp(x;d) which is defined as
clamp((x-inf(d))/wid(d)); the latter should degenerate to a step function if
the denominator is zero, i.e., if d is a singleton. They are important
building blocks in signal generation, too, particularly computer graphics.
The functions odd(x) and clamp(x;d) are a little tricky for users to
implement on their own, and may give suprising results if done so naively,
e.g., odd(1e30) should be 0 and not some large negative number and
clamp(0;0) should be 1 not NaN! Similarly, repeat([-100,100]) should give
the tight interval enclosure [0,1] not some excessively pessimistic
enclosure (accordingly for the repeat1 and fraction functions).
Implementations of these functions typically map efficiently to intrinsic
hardware instructions, anyways. All of these reasons, I think, might make
them good candidiates for standard library routines.
Maybe it is too much to ask some implementations (such as embedded
systems, for example) to support transcendental functions, I don't know. If
1788 does provide a list of required and recommended functions, it might be
better to make all the non-transcendental functions required (with a few
exceptions, perhaps, like sqrt) and the trascendental functions optional. From
an implementor's perspective, it doesn't make much sense to require hyperbolic
trig functions but not floor, ceil or abs.
Nate Hayes
P.S. I like your inclusion and definition of sign3(x) and rSqrt(x) in the
motion, although IMO they should be called sgn(x) and either invsqrt(x) or
rsqrt(x), respectively.
P.P.S. I defer to Dan Zuras on the entire pow issue. :-)