Discussion:
[ast-developers] Nan payloads research
Cedric Blancher
2013-11-21 11:57:29 UTC
Permalink
http://webcache.googleusercontent.com/search?q=cache:ysNpbShMwdwJ:www.open-std.org/jtc1/sc22/wg14/www/docs/n1755.pdf+&cd=40&hl=de&ct=clnk&gl=de
has an interesting comment about Nan payloads:

In added F.10.13, insert the paragraph:
IEC 60559 defines the payload of a quiet or signaling
NaN as an integer value encoded in the significand.
The payload is intended to represent implementation-
defined diagnostic information about the NaN. The
functions in this clause enable getting and setting
payloads.

Does anyone know how the set/get functions are named and how they work?

Ced
--
Cedric Blancher <cedric.blancher at gmail.com>
Institute Pasteur
Glenn Fowler
2013-11-21 13:34:00 UTC
Permalink
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without resorting
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf() etc.
this is what i was anticipating in the ast nan payload patch

the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than the
largest native integer


On Thu, Nov 21, 2013 at 6:57 AM, Cedric Blancher
Post by Cedric Blancher
http://webcache.googleusercontent.com/search?q=cache:ysNpbShMwdwJ:www.open-std.org/jtc1/sc22/wg14/www/docs/n1755.pdf+&cd=40&hl=de&ct=clnk&gl=de
IEC 60559 defines the payload of a quiet or signaling
NaN as an integer value encoded in the significand.
The payload is intended to represent implementation-
defined diagnostic information about the NaN. The
functions in this clause enable getting and setting
payloads.
Does anyone know how the set/get functions are named and how they work?
Ced
--
Cedric Blancher <cedric.blancher at gmail.com>
Institute Pasteur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131121/e2e40190/attachment.html>
Cedric Blancher
2013-11-21 14:05:01 UTC
Permalink
Post by Glenn Fowler
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
What are the exact prototypes for a float, double and long double arguments?
Post by Glenn Fowler
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without resorting
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf() etc.
this is what i was anticipating in the ast nan payload patch
the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than the
largest native integer
nans can only be positive integers >= 1

Ced
--
Cedric Blancher <cedric.blancher at gmail.com>
Institute Pasteur
Glenn Fowler
2013-11-21 14:36:29 UTC
Permalink
On Thu, Nov 21, 2013 at 9:05 AM, Cedric Blancher
Post by Cedric Blancher
Post by Glenn Fowler
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
What are the exact prototypes for a float, double and long double arguments?
Post by Glenn Fowler
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without
resorting
Post by Glenn Fowler
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf() etc.
this is what i was anticipating in the ast nan payload patch
the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than
the
Post by Glenn Fowler
largest native integer
nans can only be positive integers >= 1
the proposed api probably needs some tightening
its does not mention what is returned for a nan that has no payload
specified
like you note it only allows positive integer payloads which excludes 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131121/70ab69bc/attachment.html>
Cedric Blancher
2013-11-21 15:23:02 UTC
Permalink
On Thu, Nov 21, 2013 at 9:05 AM, Cedric Blancher <cedric.blancher at gmail.com>
Post by Cedric Blancher
Post by Glenn Fowler
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
What are the exact prototypes for a float, double and long double arguments?
Post by Glenn Fowler
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without resorting
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf() etc.
this is what i was anticipating in the ast nan payload patch
the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than the
largest native integer
nans can only be positive integers >= 1
the proposed api probably needs some tightening
its does not mention what is returned for a nan that has no payload
specified
Its undefined and implementation specific? :)
like you note it only allows positive integer payloads which excludes 0
Well, that's the mathematics viewpoint. The C datatypes are always
positive or negative.

Ced
--
Cedric Blancher <cedric.blancher at gmail.com>
Institute Pasteur
Glenn Fowler
2013-11-21 15:27:28 UTC
Permalink
On Thu, Nov 21, 2013 at 10:23 AM, Cedric Blancher <cedric.blancher at gmail.com
Post by Cedric Blancher
On Thu, Nov 21, 2013 at 9:05 AM, Cedric Blancher <
cedric.blancher at gmail.com>
On 21 November 2013 14:34, Glenn Fowler <glenn.s.fowler at gmail.com>
Post by Glenn Fowler
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
What are the exact prototypes for a float, double and long double arguments?
Post by Glenn Fowler
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without resorting
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf()
etc.
Post by Glenn Fowler
this is what i was anticipating in the ast nan payload patch
the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than the
largest native integer
nans can only be positive integers >= 1
the proposed api probably needs some tightening
its does not mention what is returned for a nan that has no payload
specified
Its undefined and implementation specific? :)
getpayload() would need an error indication or the whole api would be
useless (no way to determine nan that has no payload)
presumably they expect the caller to have somehow verified isnan(x) before
calling getpayload(&x)
it would then be reasonable to return 0 for nans with no payload
Post by Cedric Blancher
like you note it only allows positive integer payloads which excludes 0
Well, that's the mathematics viewpoint. The C datatypes are always
positive or negative.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.research.att.com/pipermail/ast-developers/attachments/20131121/b1a55bb4/attachment-0001.html>
Cedric Blancher
2013-11-21 15:30:09 UTC
Permalink
Post by Glenn Fowler
On Thu, Nov 21, 2013 at 10:23 AM, Cedric Blancher
Post by Cedric Blancher
Post by Glenn Fowler
On Thu, Nov 21, 2013 at 9:05 AM, Cedric Blancher
<cedric.blancher at gmail.com>
Post by Cedric Blancher
Post by Glenn Fowler
nice find
proposed descriptions for getpayload[fl]() setpayload[fl]()
What are the exact prototypes for a float, double and long double arguments?
Post by Glenn Fowler
setpayloadsig[fl]() are in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1664.pdf
as a bonus these functions provide a way to create a nan without resorting
to strtod("nan",0)
i.e., exactly what ast need because it provides strtod() sfscanf() etc.
this is what i was anticipating in the ast nan payload patch
the only disconnect is that the api deals with floating payloads but
describes the payloads themselves as non-negative integers
I guess they do this in case the largest payload value is greater than
the
largest native integer
nans can only be positive integers >= 1
the proposed api probably needs some tightening
its does not mention what is returned for a nan that has no payload
specified
Its undefined and implementation specific? :)
getpayload() would need an error indication or the whole api would be
useless (no way to determine nan that has no payload)
presumably they expect the caller to have somehow verified isnan(x) before
calling getpayload(&x)
it would then be reasonable to return 0 for nans with no payload
Ah. I understand now. Nans always have a payload. IEEE754 defines the
floating point types that way. The question, as Roland found out, is
which value is the default nan payload used by the NAN macro and the
nan("") function.

Ced
--
Cedric Blancher <cedric.blancher at gmail.com>
Institute Pasteur
Loading...