Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Uncle George <gatgul@voicenet.com>
To: axp-list@redhat.com
Subject: long->double->long goes negative
Date: Thu, 28 Sep 2000 19:44:42 -0500	[thread overview]
Message-ID: <39D3E5FA.E6BB8539@voicenet.com> (raw)

What is wrong with this picture: Somehow I expected a positive number &
a result like 0x7fffffffffffffffL
Am I expecting too much:   signed - floating point blues.

results are: lb=9223372036854775807,
                    db=(9.223372036854775808e+18, 43e0000000000000),
                    la=-9223372036854775808

main()
{
        long lb,la;
        double db,da;
        union { long    q;  double  d;  } u;
        lb =0x7fffffffffffffffL;
        db = (double) lb;
        la = (long) db;
        u.d = db;
        printf("lb=%ld, db=(%23.18e, %lx), la=%ld\n", lb, db,u.q, la);
}

cc -g -mieee a.c
./a.out






             reply	other threads:[~2000-09-29  1:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-29  0:44 Uncle George [this message]
2000-09-29  4:09 ` long->double->long goes negative Brad Lucier
2000-09-29  9:41   ` Uncle George
2000-09-29  9:56     ` Dr. David Gilbert
2000-09-29 10:57       ` Uncle George
2000-09-29 11:55         ` Dr. David Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2000-09-29  7:49 Phil Carmody
2000-09-29 11:58 Rick Gorton
2000-09-29 14:43 ` Uncle George
2000-09-29 16:36 Brad Lucier
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox