![]() |
|
|
#1 |
|
Nov 2010
22·19 Posts |
Hi,
funny thing - just discovered that gcc supports 128-bit IEEE 754 floating type. Probably it is not a speed monster, but maybe someone will find it useful. Code:
#include <stdio.h>
#include <stdint.h>
#include <endian.h>
typedef union
{
__float128 val;
struct
{
#if __BYTE_ORDER == __BIG_ENDIAN
uint64_t sign : 1;
uint64_t exp : 15;
uint64_t frac1 : 48;
uint64_t frac0 : 64;
#else
uint64_t frac0 : 64;
uint64_t frac1 : 48;
uint64_t exp : 15;
uint64_t sign : 1;
#endif
} bits;
} qfloat;
int main()
{
qfloat foo;
qfloat bar;
foo.val = 65536.0;
foo.val += 1.0;
foo.val *= foo.val;
bar.val = 8191.0;
printf("%04X %012llX %016llX\n", (uint16_t)foo.bits.exp, (uint64_t)foo.bits.frac1, foo.bits.frac0);
return 0;
}
|
|
|
|
|
|
#2 |
|
∂2ω=0
Sep 2002
República de California
1163910 Posts |
I just tried building my first program using __float128. Most everything builds OK, but I am getting compile-time warnings (have not tried to link yet, since these tell me I'm missing something) which appear to indicate a header file is needed:
warning: implicit declaration of function ‘fabsq’ The math-lib functions are enumerated here, but no mention of "you must include <blah.h>". |
|
|
|
|
|
#3 | |
|
Dec 2008
179 Posts |
Quote:
|
|
|
|
|
|
|
#4 | |
|
∂2ω=0
Sep 2002
República de California
103·113 Posts |
Quote:
But I fail to find quadmath.h anywhere on my system (I used 'locate' instead of 'find', since that is much faster, after the one-time expense of building the locate DB). I find other headers I know are there using 'locate', so the utility is working properly. Note I'm using gcc 4.2, which does recognize the __float128 type - do I need something more recent than that? |
|
|
|
|
|
|
#5 | ||
|
Dec 2008
179 Posts |
Quote:
Quote:
|
||
|
|
|