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 1745A2F0EE for ; Fri, 29 Sep 2000 08:12:01 -0400 (EDT) Received: (from mail@localhost) by mail.redhat.com (8.11.0/8.8.7) id e8TCC0n21081 for axp-list@listman.redhat.com; Fri, 29 Sep 2000 08:12:00 -0400 Received: from alpha-gw.alpha-processor.com (alpha-gw.alpha-processor.com [192.233.59.9]) by mail.redhat.com (8.11.0/8.8.7) with SMTP id e8TCC0D21077 for ; Fri, 29 Sep 2000 08:12:00 -0400 Received: from barracuda.alpha-processor.com by alpha-gw.alpha-processor.com via smtpd (for mail.redhat.com [199.183.24.239]) with SMTP; 29 Sep 2000 12:11:06 UT Received: by barracuda.api-networks.com with Internet Mail Service (5.5.2650.21) id ; Fri, 29 Sep 2000 07:58:38 -0400 Message-ID: <051DFF3BBA73D3119A5800A0C95BD021642E65@barracuda.api-networks.com> From: Rick Gorton To: "'axp-list@redhat.com'" Subject: RE: long->double->long goes negative Date: Fri, 29 Sep 2000 07:58:37 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" 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 I suggest that you peruse a copy of ieee754-1985, the ieee floating point specification for a detailed description of why some of these things can and do happen. You're working on the edge cases of IEEE, and those are fairly tricky. A quick rule-of-thumb is that it is fair to assume that any floating point value can vary by an amount equal to the value of the least significant bit for any operation. /-- 0x7fffffff fffffffe 0x7fffffff ffffffff \-- 0x80000000 00000000 /-- 0x3fefffff ffffffff 0x3ff00000 00000000 \-- 0x3ff00000 00000001 Input Input + 0.0e0 There are other things which affect the result, such as an odd-even when to add, and when not to. Another thing you can look at is paranoia.c (from someplace on the net) which I think has commentary in the code about what's happening. Yeah, sometimes it's counter-intuitive. Rick