[Cfp-interest 2686] Re: incorrect example H.12.2p4

Jim Thomas jaswthomas at sbcglobal.net
Sun Feb 5 21:10:32 PST 2023


The thread

[Cfp-interest 2665] incorrect example H.12.2p4  <http://mailman.oakapple.net/pipermail/cfp-interest/2023-January/002679.html>  <> Vincent Lefevre
[Cfp-interest 2666] Re: incorrect example H.12.2p4  <http://mailman.oakapple.net/pipermail/cfp-interest/2023-January/002680.html>  <> Vincent Lefevre

points out that the example in H.12.2p4 has a locale dependency that is not mentioned. In particular, determination of the value of MAXSIZE assumes the decimal-point is just one byte. Per discussion at the 20230131 CFP meeting, this might be fixed with the following changes:

change

#define MAXSIZE 41 // > intermediate hex string length

to

#define MAXSIZE 41 // > intermediate hex string length for “C” locale

and change

The array s for the output of strfromencf128 need have no greater size than 41, ...

to

Assuming a one byte decimal-point character as in the “C” locale, the array s for the output of strfromencf128 need have no greater size than 41, ...

- Jim Thomas

> On Jan 31, 2023, at 7:19 AM, Vincent Lefevre <vincent at vinc17.net> wrote:
> 
> The example in H.12.2p4
> 
> #define __STDC_WANT_IEC_60559_TYPES_EXT__
> #include <stdlib.h>
> #define MAXSIZE 41 // > intermediate hex string length
> unsigned char b128[16]; // for input binary128 datum
> _Decimal128 d128; // for result
> char s[MAXSIZE];
> // store input binary128 datum in array b128
> ...
> strfromencf128(s, MAXSIZE, "%a", b128);
> d128 = strtod128(s, NULL);
> ...
> 
> assumes that decimal-point takes only 1 byte. But this might not
> be true in some locales. I don't know whether this has already
> been seen in real locales, but it is known that thousands_sep
> can take several bytes in practice, e.g. with "fr_FR.utf8":
> https://reviews.llvm.org/D27167 says that thousands_sep is U+00A0
> on FreeBSD 11. And on Linux, it is U+202F NARROW NO-BREAK SPACE,
> i.e. the string e2 80 af (3 bytes).
> 
> -- 
> Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230205/179138c6/attachment-0001.htm>


More information about the Cfp-interest mailing list