[Cfp-interest 1568] TS3 and 754 format conversions

Jim Thomas jaswthomas at sbcglobal.net
Thu Apr 30 17:30:34 PDT 2020


754 5.4.2 say:

"Implementations shall provide the following formatOf conversion operations from all supported floating-point formats to all supported floating-point formats, as well as conversions to and from decimal character sequences. Some format conversion operations produce results in a different radix than the operands."

TS 18661-3 adds C support for interchange and extended types and non-arithmetic interchange formats. Ideally it would include all the conversions required by 754. Our working draft of TS3-as-annex (X.4.3) has a list of how the various conversions are supported that is intended to be complete. However, I think it falls short in two ways.

Problem 1. The methods described for mixed radix conversions using composition of string conversion functions don’t work for conversions from binary format to decimal format. The exact conversion from binary to string generally requires a hexadecimal string representation. But C doesn’t allow the string input for conversion to decimal format to be hexadecimal. Nor does 754 (5.12.3) require or recommend that conversion from string to decimal accept hexadecimal input.

Is there a way to do these conversions with the functionality we already have in TS 18661?

Or should we consider enhancing conversions between decimal formats and strings to handle hexadecimal? (After all, conversions between binary and stings have to handle decimal.)

An alternate approach would be to add functions that convert between binary and decimal encodings (dMbinencfN, dMdecencfN, fMbinencdN, fMdecencdN)? This would take care of conversions between non-arithmetic formats and (with existing conversions between types and encodings) take care of conversions between arithmetic interchange and non-arithmetic formats. However, it wouldn’t address problem 2.

Problem 2. The listed conversion cases (X.4.3) don’t include conversions between extended formats and non-arithmetic interchange formats.

The method of using string conversions would handle these cases, except for the aforementioned limitation of string to decimal conversions not allowing hexadecimal input.

It looks like enhancing conversions from string to decimal formats to accept hexadecimal input would enable us to address both these problem. (Completeness might suggest similarly enhancing conversions from decimal formats to string to produce hexadecimal output.)

Your thoughts?

- Jim Thomas





More information about the Cfp-interest mailing list