Here is the relevant information:
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <endian.h>
- #include <stdint.h>
- #if BYTE_ORDER == 1234
- #define N0of2 0
- #define N1of2 1
- #elif BYTE_ORDER == 4321
- #define N0of2 1
- #define N1of2 0
- #endif
- union UINT128 {
- uint64_t d[2];
- uint32_t i[4];
- uint16_t s[8];
- uint8_t c[16];
- } __attribute__((packed)) ;
Expand|Select|Wrap|Line Numbers
- struct F144S {
- #if __FLOAT_WORD_ORDER==1234
- UINT128 mant;
- int16_t exp;
- #elif __FLOAT_WORD_ORDER==4321
- int16_t exp;
- UINT128 mant;
- #endif
- } __attribute__((packed)) ;
- #include <ctype.h>
- class float144 {
- public:
- union f_144 {
- uint8_t c[18];
- uint16_t s[9];
- struct F144S f; } fl;
- float144() { }
- float144(f_144 x) { fl=x; }
- // XXXX
- };
float144 ten1() { fl.f.exp=(0x4002); fl.f.mant.d[N1of2]=0x4000000000000000; fl.f.mant.d[N0of2]=0; return fl; }
I get something that can serve as a constant, but I don't like carrying around the parentheses. I want something like
static const float144 ten1 { ten1.f.exp=0x4002; ten1.f.mant.d[N1of2]=0x4000000000000000; ten1.f.mant.d[N0of2]=0; };
but after 2 days, I've been unable to find anything the gcc compiler will accept.