Discussion:
Suffix for 128 bit doubles
(too old to reply)
jacob navia
2016-04-19 17:50:44 UTC
Permalink
Raw Message
Hi

If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.

For instance the number 1234:

1.234e4f128
or
1.234E4F128

Problem:

This is difficult to read. The numbers "128" tend to be confused as part
of a number.

Solutions?

Maybe

1.234e4_F128

or (preferred)

1.234e4LL

What is the good solution?
s***@casperkitty.com
2016-04-19 18:27:41 UTC
Permalink
Raw Message
Post by jacob navia
Maybe
1.234e4_F128
or (preferred)
1.234e4LL
What is the good solution?
If I were designing the language, I would have treat unsuffixed real-number
values as a compiler-only type which would, when combined with any other
floating-point type, be subjected to balancing promotion with that type.
If `r` is an extended-precision floating-point type, cases where a programmer
would want to multiply `r` by 3602879701896397/36028797018963968 are apt to
be far less common than those where a programmer would want to multiply by
the extended-precision value nearest 1/10, so having the shortest
representation (r*0.1) represent the case which is very seldom wanted but
very likely to be used accidentally would seem unhelpful.

While compatibility with existing code would probably be necessary to make
unsuffixed literals balance to at least "double", I see little benefit to
having them rounded to "double" when used in operations with larger types.
If suffixes were only necessary in cases where the programmer wanted to
perform an operand between a value of one type and a constant of another,
the use of suffixes in those cases would improve legibility rather than
adding visual clutter.
Keith Thompson
2016-04-19 19:03:35 UTC
Permalink
Raw Message
Post by jacob navia
If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.
1.234e4f128
or
1.234E4F128
There's nothing like that in the C standard. The standard only defines
'f' or 'F' for float, and 'l' or 'L' for long double. There's no
requirement to support 128-bit floating-point, and no standard typedef
or macro to denote such a type if it is supported. (There's no standard
header that does for floating-point types what <stdint.h> does for
integer types). None of the compilers I've tried recognize the "f128"
suffix.

Where did you see that?

[...]
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Philipp Klaus Krause
2016-04-19 21:09:09 UTC
Permalink
Raw Message
Post by Keith Thompson
Post by jacob navia
If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.
1.234e4f128
or
1.234E4F128
There's nothing like that in the C standard. The standard only defines
'f' or 'F' for float, and 'l' or 'L' for long double. There's no
requirement to support 128-bit floating-point, and no standard typedef
or macro to denote such a type if it is supported. (There's no standard
header that does for floating-point types what <stdint.h> does for
integer types). None of the compilers I've tried recognize the "f128"
suffix.
Where did you see that?
[...]
Technical Specification 18661: Floating-point extensions for C.

Philipp
Keith Thompson
2016-04-19 21:30:43 UTC
Permalink
Raw Message
Post by Philipp Klaus Krause
Post by Keith Thompson
Post by jacob navia
If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.
1.234e4f128
or
1.234E4F128
There's nothing like that in the C standard. The standard only defines
'f' or 'F' for float, and 'l' or 'L' for long double. There's no
requirement to support 128-bit floating-point, and no standard typedef
or macro to denote such a type if it is supported. (There's no standard
header that does for floating-point types what <stdint.h> does for
integer types). None of the compilers I've tried recognize the "f128"
suffix.
Where did you see that?
[...]
Technical Specification 18661: Floating-point extensions for C.
There are links to drafts here:

http://en.cppreference.com/w/c/experimental

Do you happen to know which one specifies the "f128" suffix syntax?
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Philipp Klaus Krause
2016-04-19 21:39:59 UTC
Permalink
Raw Message
Post by Keith Thompson
Post by Philipp Klaus Krause
Post by Keith Thompson
Post by jacob navia
If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.
1.234e4f128
or
1.234E4F128
There's nothing like that in the C standard. The standard only defines
'f' or 'F' for float, and 'l' or 'L' for long double. There's no
requirement to support 128-bit floating-point, and no standard typedef
or macro to denote such a type if it is supported. (There's no standard
header that does for floating-point types what <stdint.h> does for
integer types). None of the compilers I've tried recognize the "f128"
suffix.
Where did you see that?
[...]
Technical Specification 18661: Floating-point extensions for C.
http://en.cppreference.com/w/c/experimental
Do you happen to know which one specifies the "f128" suffix syntax?
Part 3, draft in N1945.

Philipp
BGB
2016-04-20 04:26:59 UTC
Permalink
Raw Message
Post by jacob navia
Hi
If I understood correctly the suffix for 128 bit floating point data is
f128 or F128.
1.234e4f128
or
1.234E4F128
This is difficult to read. The numbers "128" tend to be confused as part
of a number.
Solutions?
Maybe
1.234e4_F128
or (preferred)
1.234e4LL
What is the good solution?
IIRC: I generally went with 'G'.

ex: 3.1415926535897932384626433832795G

similar goes for using 'LX' and 'ULX' as a suffix for 128 bit integers.


for type names, generally went with __float128, __int128, and __uint128.

don't know about "conventional" names, IIRC, some people had gone with
(or leaned towards) "long long double", "long long long", and "unsigned
long long long", but these seem a little silly IMHO...

though, compiler support is a bit hit-or-miss for anything beyond 64
bits, and those compilers which do support 128 bit types tend to require
running on a 64-bit target.

though, granted, I haven't looked into all this in all that much detail.
Loading...