[Cfp-interest] Not trigger sNaN

Fred J. Tydeman tydeman at tybor.com
Tue Aug 28 19:16:56 PDT 2018


On Tue, 28 Aug 2018 13:13:45 -0500 Rajan Bhakta wrote:
>
>          *AI*: Fred: See which other functions have the need to not 
>trigger signaling nans but are functions (need to be macros).

754 Operations that shall not trigger an sNaN (signal invalid):

"*" are functions in C

copy() = memcpy()*, memmove()* via pointers
negate()
abs() = fabs()*
copySign() = copysign()*

encodeDecimal() = encodedec()* via pointers
decodeDecimal() = decodedec()* via pointers
encodeBinary() = encodebin()* via pointers
decodeBinary() = decodebin()* via pointers

class() = fpclassify()
isSignMinus() = signbit()
isNormal() = isnormal()
isFinite() isfinite()
isZero() = iszero()
isSubnormal() = issubnormal()
isInfinite() = isinf()
isNaN() = isnan()
isSignaling() = issignaling()
isCanonical() = iscanonical()
radix()
totalOrder() = totalorder()*
totalOrderMag() =totalordermag()*

sameQuantum() = samequantum()*

getPayload() = getpayload()* via pointer
setPayload() = setpayload()* via pointer
setPayloadSignaling() = setpayloadsig()* via pointer

754 Operations that should not trigger an sNaN:

fp->char = printf()*
char->fp = scanf()* via pointer


Given that some of the above are done (in C) as macros and others as
functions, implementations may have to use macros for the functions
and compiler magic to avoid triggering an sNaN.  Not sure how well
that will work for function pointers or type generic macros.

Another idea is a special calling convention that avoids triggering an
sNaN.

Whatever is used, it should work for constants, variables, and
expressions.

The functions without pointers are:
fabs()
copysign()
totalorder()
totalordermag()
samequantum()
printf()



---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list