From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.redhat.com (mail.redhat.com [199.183.24.239]) by listman.redhat.com (Postfix) with ESMTP id 168D22F1D4 for ; Fri, 29 Sep 2000 05:40:25 -0400 (EDT) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id e8T9eOS28107 for axp-list@listman.redhat.com; Fri, 29 Sep 2000 05:40:24 -0400 Received: from voicenet.com (mail11.voicenet.com [207.103.0.37]) by mail.redhat.com (8.11.0/8.8.7) with SMTP id e8T9eOD28099 for ; Fri, 29 Sep 2000 05:40:24 -0400 Received: (qmail 12783 invoked from network); 29 Sep 2000 09:40:23 -0000 Received: from dialpool0236-pri.dialpool02.voicenet.com (HELO voicenet.com) (209.71.85.103) by mail11.voicenet.com with SMTP; 29 Sep 2000 09:40:23 -0000 Message-ID: <39D463D1.945DF157@voicenet.com> Date: Fri, 29 Sep 2000 04:41:37 -0500 From: Uncle George Organization: GatWorks X-Mailer: Mozilla 4.72 [en] (X11; I; Linux 2.2.16 alpha) X-Accept-Language: en MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: long->double->long goes negative References: <200009290409.XAA20223@polya.math.purdue.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Loop: axp-list@redhat.com Sender: axp-list-admin@redhat.com Errors-To: axp-list-admin@redhat.com X-BeenThere: axp-list@redhat.com X-Mailman-Version: 2.0beta4 Precedence: bulk Reply-To: axp-list@redhat.com List-Id: Linux and Red Hat on Alpha processors so u expect +int -> +float -> -int to be an A-OK situation. Gee what other positive float numbers would u expect to give u negative results. it should be either a 0, or a long.MAX value. going neg ( or long.MIN ) is not reasonable or rational /gat In my opinion, the results would be ok if it was converted to an unsigned long. Then the high order bit would not be representative of a sign bit. Brad Lucier wrote: > Well, I don't find your posting very clear, but it doesn't seem > that strange to me. Perhaps I'm missing something. > > > main() > > { > > long lb,la; > > double db,da; > > union { long q; double d; } u; > > lb =0x7fffffffffffffffL; > > db = (double) lb; > > db has only 53 bits mantissa, so lb cannot have all its 63 bits > represented exactly, and on conversion lb is rounded to > the nearest number, which happens to be 9.223372036854775808e+18 > > > la = (long) db; > > Here db does have an integral value, but that value is bigger than > the largest long, so it can't be represented exactly as a long; > the bit pattern of the converted result is 0x8000000000000000, > which doesn't seem such a bad choice in this situation. > > > 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 > > _______________________________________________ > Axp-list mailing list > Axp-list@redhat.com > https://listman.redhat.com/mailman/listinfo/axp-list