Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #81702 > unrolled thread
| Started by | wij <wyniijj@gmail.com> |
|---|---|
| First post | 2021-10-01 08:37 -0700 |
| Last post | 2021-10-03 18:46 -0700 |
| Articles | 20 on this page of 103 — 17 participants |
Back to article view | Back to comp.lang.c++
How to get mantissa of long double? wij <wyniijj@gmail.com> - 2021-10-01 08:37 -0700
Re: How to get mantissa of long double? RadicalRabbit@theburrow.co.uk - 2021-10-01 16:09 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-01 14:05 -0400
Re: How to get mantissa of long double? wij <wyniijj@gmail.com> - 2021-10-01 17:23 -0700
Re: How to get mantissa of long double? Manfred <noname@add.invalid> - 2021-10-02 18:58 +0200
Re: How to get mantissa of long double? Manfred <noname@add.invalid> - 2021-10-02 19:21 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-01 19:18 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-01 19:20 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-01 19:25 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-01 19:53 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-03 08:09 +0200
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-03 11:15 +0100
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-03 12:19 +0200
Re: How to get mantissa of long double? red floyd <no.spam@its.invalid> - 2021-10-03 18:03 -0700
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-04 09:52 +0200
Re: How to get mantissa of long double? Juha Nieminen <nospam@thanks.invalid> - 2021-10-04 09:59 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-04 13:50 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-04 20:04 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-05 07:12 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-05 09:47 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-05 16:46 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-05 19:04 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-05 19:13 +0200
Re: How to get mantissa of long double? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-10-05 09:04 -0700
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-05 19:14 +0200
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-05 19:21 +0100
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 07:58 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-06 08:11 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 10:25 +0200
Re: How to get mantissa of long double? scott@slp53.sl.home (Scott Lurndal) - 2021-10-06 14:25 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 16:53 +0200
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-06 12:12 +0100
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 14:48 +0200
Re: How to get mantissa of long double? red floyd <no.spam.here@its.invalid> - 2021-10-06 09:44 -0700
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 18:52 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-06 19:02 +0200
Re: How to get mantissa of long double? Juha Nieminen <nospam@thanks.invalid> - 2021-10-07 05:35 +0000
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-07 08:20 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-07 08:38 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-07 08:42 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-07 10:23 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-08 20:23 +0200
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-09 10:23 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-09 10:50 +0200
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-09 09:02 +0000
Re: How to get mantissa of long double? scott@slp53.sl.home (Scott Lurndal) - 2021-10-09 14:57 +0000
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-09 12:16 +0100
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-09 15:10 +0200
Re: How to get mantissa of long double? red floyd <no.spam.here@its.invalid> - 2021-10-09 10:26 -0700
Re: How to get mantissa of long double? Vir Campestris <vir.campestris@invalid.invalid> - 2021-10-12 21:23 +0100
Re: How to get mantissa of long double? RadicalRabbit@theburrow.co.uk - 2021-10-13 10:30 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-07 08:38 +0200
Re: How to get mantissa of long double? Juha Nieminen <nospam@thanks.invalid> - 2021-10-08 04:37 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-08 07:54 +0200
Re: How to get mantissa of long double? red floyd <no.spam.here@its.invalid> - 2021-10-07 22:44 -0700
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-07 08:17 +0200
Re: How to get mantissa of long double? Juha Nieminen <nospam@thanks.invalid> - 2021-10-08 04:39 +0000
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-08 09:25 +0200
Re: How to get mantissa of long double? scott@slp53.sl.home (Scott Lurndal) - 2021-10-08 14:34 +0000
Re: How to get mantissa of long double? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-10-06 13:57 -0700
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 19:34 +0000
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 19:33 +0000
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-05 10:19 +0000
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-04 14:06 +0100
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-04 16:12 +0200
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 16:15 +0000
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 16:15 +0000
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-05 09:48 +0200
Re: How to get mantissa of long double? Juha Nieminen <nospam@thanks.invalid> - 2021-10-05 05:19 +0000
Re: How to get mantissa of long double? David Brown <david.brown@hesbynett.no> - 2021-10-05 10:00 +0200
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-05 16:47 +0200
Re: How to get mantissa of long double? scott@slp53.sl.home (Scott Lurndal) - 2021-10-04 14:37 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-04 16:53 +0200
Re: How to get mantissa of long double? scott@slp53.sl.home (Scott Lurndal) - 2021-10-04 17:08 +0000
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-04 20:22 +0100
Re: How to get mantissa of long double? Bart <bc@freeuk.com> - 2021-10-01 19:09 +0100
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-01 20:16 +0200
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-01 18:53 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-01 20:19 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-02 02:16 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-02 01:28 -0400
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-02 01:56 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-02 10:59 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-02 14:57 -0400
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-02 15:37 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-03 00:47 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-03 23:42 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 04:35 +0000
Re: How to get mantissa of long double? Bonita Montero <Bonita.Montero@gmail.com> - 2021-10-02 12:09 +0200
Re: How to get mantissa of long double? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2021-10-02 21:00 +0200
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-02 15:12 -0400
Re: How to get mantissa of long double? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2021-10-02 21:23 +0200
Re: How to get mantissa of long double? "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2021-10-02 21:27 +0200
Re: How to get mantissa of long double? Manfred <noname@add.invalid> - 2021-10-02 23:19 +0200
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-03 23:43 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-03 00:45 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-03 23:31 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 04:34 +0000
Re: How to get mantissa of long double? James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-10-04 11:30 -0400
Re: How to get mantissa of long double? Branimir Maksimovic <branimir.maksimovic@icloud.com> - 2021-10-04 16:19 +0000
Re: How to get mantissa of long double? wij <wyniijj@gmail.com> - 2021-10-03 00:35 -0700
Re: How to get mantissa of long double? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-10-03 15:02 +0100
Re: How to get mantissa of long double? wij <wyniijj@gmail.com> - 2021-10-03 18:46 -0700
Page 2 of 6 — ← Prev page 1 [2] 3 4 5 6 Next page →
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-05 16:46 +0200 |
| Message-ID | <sjhof9$p11$1@dont-email.me> |
| In reply to | #81853 |
Am 05.10.2021 um 09:47 schrieb David Brown: >> There isn't any ARM-implementation with 128 bit FP. > And you know that because ... what? Because you are confusing hardware > floating point with floating point in general? There isn't even an ISA-spec. Its just an ABI. > There are very few /hardware/ implementations of quad precision floating > point - I think perhaps Power is the only architecture that actually has > it in practice. (Some architectures, such as SPARC and RISC-V, have > defined them in the architecture but have no physical devices supporting > them.) https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2021-10-05 19:04 +0200 |
| Message-ID | <sji0jo$q9a$1@dont-email.me> |
| In reply to | #81860 |
On 05/10/2021 16:46, Bonita Montero wrote: > Am 05.10.2021 um 09:47 schrieb David Brown: > >>> There isn't any ARM-implementation with 128 bit FP. > >> And you know that because ... what? Because you are confusing hardware >> floating point with floating point in general? > > There isn't even an ISA-spec. Its just an ABI. And ... so what? For all your effort trying to move the goalposts, you are still wrong - "long double" is supported, and on all larger systems with decent compilers, it is greater range and precision than "double". It's that simple. > >> There are very few /hardware/ implementations of quad precision floating >> point - I think perhaps Power is the only architecture that actually has >> it in practice. (Some architectures, such as SPARC and RISC-V, have >> defined them in the architecture but have no physical devices supporting >> them.) > > https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format Yes, I have read that. Have you? Did you notice where it contradicted your claims?
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-05 19:13 +0200 |
| Message-ID | <sji13c$u7b$1@dont-email.me> |
| In reply to | #81863 |
Am 05.10.2021 um 19:04 schrieb David Brown: > On 05/10/2021 16:46, Bonita Montero wrote: >> Am 05.10.2021 um 09:47 schrieb David Brown: >> >>>> There isn't any ARM-implementation with 128 bit FP. >> >>> And you know that because ... what? Because you are confusing hardware >>> floating point with floating point in general? >> >> There isn't even an ISA-spec. Its just an ABI. > > And ... so what? For all your effort trying to move the goalposts, > you are still wrong - "long double" is supported, ... But not on the ISA-level. So it's all up to the compiler and runtime.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2021-10-05 09:04 -0700 |
| Message-ID | <87r1cz8nlm.fsf@nosuchdomain.example.com> |
| In reply to | #81853 |
David Brown <david.brown@hesbynett.no> writes:
> On 05/10/2021 07:12, Bonita Montero wrote:
>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>
>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other 64-bit
>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE quad
>>> precision). For RISC-V, even 32-bit targets have 128-bit "long double".
>>
>> There isn't any ARM-implementation with 128 bit FP.
>
> And you know that because ... what? Because you are confusing hardware
> floating point with floating point in general?
$ uname -m
aarch64
$ cat c.c
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main(void) {
printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG = %d\n",
sizeof (long double),
CHAR_BIT * sizeof (long double),
LDBL_DIG);
}
$ gcc c.c -o c && ./c
sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
$
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-05 19:14 +0200 |
| Message-ID | <sji157$u7b$2@dont-email.me> |
| In reply to | #81862 |
Am 05.10.2021 um 18:04 schrieb Keith Thompson:
> David Brown <david.brown@hesbynett.no> writes:
>> On 05/10/2021 07:12, Bonita Montero wrote:
>>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>>
>>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other 64-bit
>>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE quad
>>>> precision). For RISC-V, even 32-bit targets have 128-bit "long double".
>>>
>>> There isn't any ARM-implementation with 128 bit FP.
>>
>> And you know that because ... what? Because you are confusing hardware
>> floating point with floating point in general?
>
> $ uname -m
> aarch64
> $ cat c.c
> #include <stdio.h>
> #include <limits.h>
> #include <float.h>
>
> int main(void) {
> printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG = %d\n",
> sizeof (long double),
> CHAR_BIT * sizeof (long double),
> LDBL_DIG);
> }
> $ gcc c.c -o c && ./c
> sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
> $
That's pure software - your CPU doesn't natively support 128 bit FP.
[toc] | [prev] | [next] | [standalone]
| From | Bart <bc@freeuk.com> |
|---|---|
| Date | 2021-10-05 19:21 +0100 |
| Message-ID | <sji534$v2o$1@dont-email.me> |
| In reply to | #81865 |
On 05/10/2021 18:14, Bonita Montero wrote:
> Am 05.10.2021 um 18:04 schrieb Keith Thompson:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 05/10/2021 07:12, Bonita Montero wrote:
>>>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>>>
>>>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other
>>>>> 64-bit
>>>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE quad
>>>>> precision). For RISC-V, even 32-bit targets have 128-bit "long
>>>>> double".
>>>>
>>>> There isn't any ARM-implementation with 128 bit FP.
>>>
>>> And you know that because ... what? Because you are confusing hardware
>>> floating point with floating point in general?
>>
>> $ uname -m
>> aarch64
>> $ cat c.c
>> #include <stdio.h>
>> #include <limits.h>
>> #include <float.h>
>>
>> int main(void) {
>> printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG = %d\n",
>> sizeof (long double),
>> CHAR_BIT * sizeof (long double),
>> LDBL_DIG);
>> }
>> $ gcc c.c -o c && ./c
>> sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
>> $
>
> That's pure software - your CPU doesn't natively support 128 bit FP.
>
Does it matter?
Suppose there /is/ a long double type which is wider than double,
however many bits it is, or whether it's implemented in hardware or
software: how do you then extract its mantissa?
I showed a non-portable way of doing when it was Intel's 80-bit type. My
method used x87 instructions, but it's actually even simpler without it:
just take the first 64 bits of the 80-bit little-endian representation.
(That only works with that 80-bit format.)
But for anything beyond 80 bits, or for something that works on any size
of float, you will need a different approach, and possibly a uint128 type.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 07:58 +0200 |
| Message-ID | <sjjdtp$p50$1@dont-email.me> |
| In reply to | #81866 |
Am 05.10.2021 um 20:21 schrieb Bart:
> On 05/10/2021 18:14, Bonita Montero wrote:
>> Am 05.10.2021 um 18:04 schrieb Keith Thompson:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>> On 05/10/2021 07:12, Bonita Montero wrote:
>>>>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>>>>
>>>>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other
>>>>>> 64-bit
>>>>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE quad
>>>>>> precision). For RISC-V, even 32-bit targets have 128-bit "long
>>>>>> double".
>>>>>
>>>>> There isn't any ARM-implementation with 128 bit FP.
>>>>
>>>> And you know that because ... what? Because you are confusing hardware
>>>> floating point with floating point in general?
>>>
>>> $ uname -m
>>> aarch64
>>> $ cat c.c
>>> #include <stdio.h>
>>> #include <limits.h>
>>> #include <float.h>
>>>
>>> int main(void) {
>>> printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG =
>>> %d\n",
>>> sizeof (long double),
>>> CHAR_BIT * sizeof (long double),
>>> LDBL_DIG);
>>> }
>>> $ gcc c.c -o c && ./c
>>> sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
>>> $
>>
>> That's pure software - your CPU doesn't natively support 128 bit FP.
>>
>
> Does it matter?
Yes, It's rare that you need 128 bit FP and it's even more rare that
the speed doesn't matter.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2021-10-06 08:11 +0200 |
| Message-ID | <sjjenc$tps$1@dont-email.me> |
| In reply to | #81869 |
On 06/10/2021 07:58, Bonita Montero wrote: > Am 05.10.2021 um 20:21 schrieb Bart: >> On 05/10/2021 18:14, Bonita Montero wrote: >>> That's pure software - your CPU doesn't natively support 128 bit FP. >>> >> >> Does it matter? > > Yes, It's rare that you need 128 bit FP and it's even more rare that > the speed doesn't matter. > Until a couple of days ago, you didn't think 128-bit floating point existed. Now you think you know how it is used and what is important to users? There was a time when /all/ floating point, at least on "normal" computers, was in software. Yet people used it - including 64-bit doubles which were much slower than 32-bit float. Then floating point co-processors became common, and made floating point somewhat faster (though still slow). And people used them. There are a great many processors that still don't have hardware floating point, and people use software floats if they need floating point. You do so because getting the correct answer is more important than getting a fast answer. If you need the greater precision or range of quad precision floating point, then you use that. If it is slow, you accept that - or you pay the price for faster hardware. There does not seem to be much call for quad precision - not enough for many cpu manufacturers to spend the significant die space needed to implement it in hardware. But there is enough call for it to be implemented in software on many tools (gcc and clang for x86 have it as __float128, and I'd be slightly surprised if MS doesn't have some support through a similar extension), it is specified in a number of cpu architecture documents for future implementation, and there are many library implementations available.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 10:25 +0200 |
| Message-ID | <sjjmhf$b7j$1@dont-email.me> |
| In reply to | #81870 |
Am 06.10.2021 um 08:11 schrieb David Brown: > Until a couple of days ago, you didn't think 128-bit floating point > existed. ... Where did I say that ? I only said that ARM 128 bit FP is just an ABI-issue.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2021-10-06 14:25 +0000 |
| Message-ID | <kli7J.103805$jl2.90612@fx34.iad> |
| In reply to | #81870 |
David Brown <david.brown@hesbynett.no> writes: >On 06/10/2021 07:58, Bonita Montero wrote: >> Am 05.10.2021 um 20:21 schrieb Bart: >>> On 05/10/2021 18:14, Bonita Montero wrote: > >>>> That's pure software - your CPU doesn't natively support 128 bit FP. >>>> >>> >>> Does it matter? >> >> Yes, It's rare that you need 128 bit FP and it's even more rare that >> the speed doesn't matter. >> > >Until a couple of days ago, you didn't think 128-bit floating point >existed. Now you think you know how it is used and what is important to >users? It seems the most popular new floating point format today is 16-bit floating point (bfloat16 in ARM) - important in machine learning applications.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 16:53 +0200 |
| Message-ID | <sjkda6$3qg$1@dont-email.me> |
| In reply to | #81874 |
Am 06.10.2021 um 16:25 schrieb Scott Lurndal: > It seems the most popular new floating point format today is 16-bit > floating point (bfloat16 in ARM) - important in machine learning > applications. I think that's popular only for KI-puposes. Even for computer graphics that's not sufficient.
[toc] | [prev] | [next] | [standalone]
| From | Bart <bc@freeuk.com> |
|---|---|
| Date | 2021-10-06 12:12 +0100 |
| Message-ID | <sjk0bc$a60$1@dont-email.me> |
| In reply to | #81869 |
On 06/10/2021 06:58, Bonita Montero wrote:
> Am 05.10.2021 um 20:21 schrieb Bart:
>> On 05/10/2021 18:14, Bonita Montero wrote:
>>> Am 05.10.2021 um 18:04 schrieb Keith Thompson:
>>>> David Brown <david.brown@hesbynett.no> writes:
>>>>> On 05/10/2021 07:12, Bonita Montero wrote:
>>>>>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>>>>>
>>>>>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other
>>>>>>> 64-bit
>>>>>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE
>>>>>>> quad
>>>>>>> precision). For RISC-V, even 32-bit targets have 128-bit "long
>>>>>>> double".
>>>>>>
>>>>>> There isn't any ARM-implementation with 128 bit FP.
>>>>>
>>>>> And you know that because ... what? Because you are confusing
>>>>> hardware
>>>>> floating point with floating point in general?
>>>>
>>>> $ uname -m
>>>> aarch64
>>>> $ cat c.c
>>>> #include <stdio.h>
>>>> #include <limits.h>
>>>> #include <float.h>
>>>>
>>>> int main(void) {
>>>> printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG =
>>>> %d\n",
>>>> sizeof (long double),
>>>> CHAR_BIT * sizeof (long double),
>>>> LDBL_DIG);
>>>> }
>>>> $ gcc c.c -o c && ./c
>>>> sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
>>>> $
>>>
>>> That's pure software - your CPU doesn't natively support 128 bit FP.
>>>
>>
>> Does it matter?
>
> Yes, It's rare that you need 128 bit FP and it's even more rare that
> the speed doesn't matter.
>
>
You keep avoiding my point
Suppose you HAVE 80-bit or 128-FP, and need to extract the mantissa, how
would you do it?
It's like someone asking how to work out the 5th root of a number, and
you give a method for the square root. Then when pressed, you say that
is is rare to need a 5th root!
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 14:48 +0200 |
| Message-ID | <sjk5vn$hbb$1@dont-email.me> |
| In reply to | #81872 |
Am 06.10.2021 um 13:12 schrieb Bart:
> On 06/10/2021 06:58, Bonita Montero wrote:
>> Am 05.10.2021 um 20:21 schrieb Bart:
>>> On 05/10/2021 18:14, Bonita Montero wrote:
>>>> Am 05.10.2021 um 18:04 schrieb Keith Thompson:
>>>>> David Brown <david.brown@hesbynett.no> writes:
>>>>>> On 05/10/2021 07:12, Bonita Montero wrote:
>>>>>>> Am 04.10.2021 um 20:04 schrieb David Brown:
>>>>>>>
>>>>>>>> MSVC for ARM has 64-bit "long doubles" even on 64-bit ARM, other
>>>>>>>> 64-bit
>>>>>>>> ARM targets have 128-bit (I don't know off-hand if they are IEEE
>>>>>>>> quad
>>>>>>>> precision). For RISC-V, even 32-bit targets have 128-bit "long
>>>>>>>> double".
>>>>>>>
>>>>>>> There isn't any ARM-implementation with 128 bit FP.
>>>>>>
>>>>>> And you know that because ... what? Because you are confusing
>>>>>> hardware
>>>>>> floating point with floating point in general?
>>>>>
>>>>> $ uname -m
>>>>> aarch64
>>>>> $ cat c.c
>>>>> #include <stdio.h>
>>>>> #include <limits.h>
>>>>> #include <float.h>
>>>>>
>>>>> int main(void) {
>>>>> printf("sizeof (long double) = %zu (%zu bits), LDBL_DIG =
>>>>> %d\n",
>>>>> sizeof (long double),
>>>>> CHAR_BIT * sizeof (long double),
>>>>> LDBL_DIG);
>>>>> }
>>>>> $ gcc c.c -o c && ./c
>>>>> sizeof (long double) = 16 (128 bits), LDBL_DIG = 33
>>>>> $
>>>>
>>>> That's pure software - your CPU doesn't natively support 128 bit FP.
>>>>
>>>
>>> Does it matter?
>>
>> Yes, It's rare that you need 128 bit FP and it's even more rare that
>> the speed doesn't matter.
>>
>>
>
> You keep avoiding my point
>
> Suppose you HAVE 80-bit or 128-FP, and need to extract the mantissa, how
> would you do it?
As the 1 high-bit is alwas included in the 64 bit mantissa of a 80 bit
FP-value that's much easier. In contrast to smaller FP-values where the
one bit implicity except from denormal values or values with the maximum
exponent.
union
{
long double value;
struct
{
uint64_t mantissa;
uint16_t exponent : 15,
sign : 1;
};
}
Just store your value into value and extract the mantissa from mantissa.
[toc] | [prev] | [next] | [standalone]
| From | red floyd <no.spam.here@its.invalid> |
|---|---|
| Date | 2021-10-06 09:44 -0700 |
| Message-ID | <sjkjpl$aa2$1@redfloyd.dont-email.me> |
| In reply to | #81873 |
On 10/6/2021 5:48 AM, Bonita Montero wrote:
>
> As the 1 high-bit is alwas included in the 64 bit mantissa of a 80 bit
> FP-value that's much easier. In contrast to smaller FP-values where the
> one bit implicity except from denormal values or values with the maximum
> exponent.
>
> union
> {
> long double value;
> struct
> {
> uint64_t mantissa;
> uint16_t exponent : 15,
> sign : 1;
> };
> }
>
> Just store your value into value and extract the mantissa from mantissa.
Does anyone know if type punning through a union is still undefined
behavior?
Also, I believe bitfield allocation is implementation defined.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 18:52 +0200 |
| Message-ID | <sjkk8p$l3a$1@dont-email.me> |
| In reply to | #81876 |
Am 06.10.2021 um 18:44 schrieb red floyd:
> On 10/6/2021 5:48 AM, Bonita Montero wrote:
>
>>
>> As the 1 high-bit is alwas included in the 64 bit mantissa of a 80 bit
>> FP-value that's much easier. In contrast to smaller FP-values where the
>> one bit implicity except from denormal values or values with the maximum
>> exponent.
>>
>> union
>> {
>> long double value;
>> struct
>> {
>> uint64_t mantissa;
>> uint16_t exponent : 15,
>> sign : 1;
>> };
>> }
>>
>> Just store your value into value and extract the mantissa from mantissa.
>
> Does anyone know if type punning through a union is still undefined
> behavior?
It's a de-facto standard for all compilers because such constructs
are needed very often.
Otherwise it's specified that you can alias anything as a array of
chars and an array of chars as anything - I think that's specified
because this is nice to have for serialization-purposes. So you can
cast a type to a char * and then further to the destination type to
get the same effect. This definitely prevents any optimization tricks
of the compiler which would sabotage this.
> Also, I believe bitfield allocation is implementation defined.
The way than I did is at least portable among x86-compilers.
On platforms where you have a differnt byte-order this won't
work, but these platforms don't have a 80 bit FP type anyway.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-06 19:02 +0200 |
| Message-ID | <sjkkrb$ol1$1@dont-email.me> |
| In reply to | #81877 |
>>> union
>>> {
>>> long double value;
>>> struct
>>> {
>>> uint64_t mantissa;
>>> uint16_t exponent : 15,
>>> sign : 1;
>>> };
>>> }
>>>
>> Also, I believe bitfield allocation is implementation defined.
> The way than I did is at least portable among x86-compilers.
> On platforms where you have a differnt byte-order this won't
> work, but these platforms don't have a 80 bit FP type anyway.
To be more precise here: there are some differences in how x86
compilers handle bitfields, but there are also commonalities.
And the binary layout of the above structure is definitely the
same for all x86-compilers.
[toc] | [prev] | [next] | [standalone]
| From | Juha Nieminen <nospam@thanks.invalid> |
|---|---|
| Date | 2021-10-07 05:35 +0000 |
| Message-ID | <sjm0ui$la0$1@gioia.aioe.org> |
| In reply to | #81876 |
red floyd <no.spam.here@its.invalid> wrote:
>> union
>> {
>> long double value;
>> struct
>> {
>> uint64_t mantissa;
>> uint16_t exponent : 15,
>> sign : 1;
>> };
>> }
>>
>> Just store your value into value and extract the mantissa from mantissa.
>
> Does anyone know if type punning through a union is still undefined
> behavior?
>
> Also, I believe bitfield allocation is implementation defined.
Also, the above union assumes that the long double value is stored in the
same byte order as the members of the struct. It also assumes that the long
double occupies exactly 10 bytes and isn't padded in the wrong end.
And, as you say, it's not defined whether that sign bit will be the lowest
or highest bit of that 16-bit bitfield. (I don't think the standard even
guarantees that the 1-bit will be stored in the same bytes as the 15-bits.)
You could make some compile-time checks to see that the union will have
the proper internal structure (and refuse to compile otherwise), although
IIRC there's no way to check endianess at compile time (unless C++20
added some new features to do that).
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2021-10-07 08:20 +0200 |
| Message-ID | <sjm3j4$r5v$2@dont-email.me> |
| In reply to | #81899 |
On 07/10/2021 07:35, Juha Nieminen wrote:
> red floyd <no.spam.here@its.invalid> wrote:
>>> union
>>> {
>>> long double value;
>>> struct
>>> {
>>> uint64_t mantissa;
>>> uint16_t exponent : 15,
>>> sign : 1;
>>> };
>>> }
>>>
>>> Just store your value into value and extract the mantissa from mantissa.
>>
>> Does anyone know if type punning through a union is still undefined
>> behavior?
>>
>> Also, I believe bitfield allocation is implementation defined.
>
> Also, the above union assumes that the long double value is stored in the
> same byte order as the members of the struct. It also assumes that the long
> double occupies exactly 10 bytes and isn't padded in the wrong end.
>
> And, as you say, it's not defined whether that sign bit will be the lowest
> or highest bit of that 16-bit bitfield. (I don't think the standard even
> guarantees that the 1-bit will be stored in the same bytes as the 15-bits.)
>
> You could make some compile-time checks to see that the union will have
> the proper internal structure (and refuse to compile otherwise), although
> IIRC there's no way to check endianess at compile time (unless C++20
> added some new features to do that).
>
C++20 added std::endian for convenience and standardisation of common
compiler features for endianness:
<https://en.cppreference.com/w/cpp/types/endian>
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-07 08:38 +0200 |
| Message-ID | <sjm4le$1f2$2@dont-email.me> |
| In reply to | #81901 |
Am 07.10.2021 um 08:20 schrieb David Brown: > C++20 added std::endian for convenience and standardisation of common > compiler features for endianness: Why an endianess check here ? There are no big-endian machines with 80 bit FP.
[toc] | [prev] | [next] | [standalone]
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Date | 2021-10-07 08:42 +0200 |
| Message-ID | <sjm4s5$2o0$1@dont-email.me> |
| In reply to | #81905 |
Am 07.10.2021 um 08:38 schrieb Bonita Montero: > Am 07.10.2021 um 08:20 schrieb David Brown: > >> C++20 added std::endian for convenience and standardisation of common >> compiler features for endianness: > > Why an endianess check here ? > There are no big-endian machines with 80 bit FP. Oh, I just remembered the 68K FPUs. These have 80 bit FP. But 68K is dead today.
[toc] | [prev] | [next] | [standalone]
Page 2 of 6 — ← Prev page 1 [2] 3 4 5 6 Next page →
Back to top | Article view | comp.lang.c++
csiph-web