Re: C language binding of P1888 operations, especially min and max
On 2013-10-04 06:12:04 -0700, Dmitry Nadezhin wrote:
> I'm trying to create a C language binding of P1788 operations.
> I assume two 754-conforming datatypes: b32 and b64.
>
> https://java.net/projects/jinterval/sources/svn/content/trunk/jinterval/p1788-launcher-java/src/main/resources/net/java/jinterval/p1788/p1788.h
>
> As there are no polymorphism in C, mixed-format operation are
> expressed by a suffix that encodes types of outputs and inputs.
> Interval datatypes are encoded by upper-case chars:
> F - infsup_b32
> D - infsup_b64
> Q - infsup_b128 // not used yet
> Number formats are encoded by lower-case chars:
> f - b32
> d - b64
> q - b128 // not used yet
> Byte/word strings are encoded:
> c - char8
> w - char16 // not used yet
I think you mean char (which doesn't necessarily have only 8 bits)
and wide char.
> Integer parametes (like p in pown(x,p) or array length in reduction operations
> are encoded:
> i - int32
> l - int64 // not used yet
In you code, you use i for int, which isn't necessarily a 32-bit type
(not to me confused with int32_t and some other C99 integer types).
> I have doubts with "min" and "max" operations.
> Section 9.1 says that they are
> "A family of functions parameterized by the arity k."
> Section 12.12 says that they are mixed-type operations.
> Section 12.6.2 sats that there shall be variants of these operations for each
> combination of interval types.
> So for each "k", it is necessary 2^(k+1) variants.
> This is a combinatoric explosure.
> How can I bind this in C ?
In IEEE 754-2008, minNum and maxNum are not formatOf operations.
For simplicity, this should be corrected in P1788.
In §12.12:
"An implementation, or a part thereof, that is 754-conforming shall
provide mixed-type operations, as specified in §12.6.2, for the
following operations, which correspond to those that 754 requires
to be provided as formatOf operations.
add, sub, mul, div, recip, sqrt, sqr, sign, ceil, floor, round, trunc,
abs, min, max, fma."
I don't know where this list comes from. This is correct for:
add, sub, mul, div, recip (due to div), sqrt, sqr (due to mul),
and fma, but not for the other ones.
IEEE 754 has formatOf float-to-int conversions, but the destination
format is an integer format, not a floating-point one.
In IEEE 754, the minNum and maxNum arity is 2. I don't have a strong
opinion on what P1788 should require about the arity.
--
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)