Le 21/08/2023 à 10:34, Laurent Vivier a écrit :
Le 20/08/2023 à 22:55, Keith Packard a écrit :
#include <stdio.h>
#include <stdint.h>

#define X       0x1p+16383l
#define Y       0x1p-16446l

static long double build_mul = X * Y;
static volatile long double x = X;
static volatile long double y = Y;

static void
dump_ld(const char *label, long double ld)
{
     union {
         long double     d;
         struct {
             uint32_t    exp:16;
             uint32_t    space:16;
             uint32_t    h;
             uint32_t    l;
         };
     } u;

     u.d = ld;
     printf("%12s: % -27La 0x%04x 0x%08x 0x%08x\n", label, u.d, u.exp, u.h, 
u.l);
}

int main(void)
{
     long double runtime_mul = x * y;

     dump_ld("x", x);
     dump_ld("y", y);
     dump_ld("build_mul", build_mul);
     dump_ld("runtime_mul", runtime_mul);
     return 0;
}

FYI, result of this program on a real hardware (q800/m68040) is:

            x:  0x8p+16380                 0x7ffe 0x80000000 0x00000000
            y:  0x0.000000000000001p-16386 0x0000 0x00000000 0x00000001
    build_mul:  0x8p-66                    0x3fc0 0x80000000 0x00000000
  runtime_mul:  0x8p-66                    0x3fc0 0x80000000 0x00000000


When I developped the FPU emulation I compared the result of QEMU and a real hardware using https://github.com/vivier/m68k-testfloat and https://github.com/vivier/m68k-softfloat

Thanks,
Laurent


Reply via email to