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: Re: long->double->long goes negative
Date: Fri, 29 Sep 2000 09:43:23 -0500	[thread overview]
Message-ID: <39D4AA8B.B2025E56@voicenet.com> (raw)
In-Reply-To: 051DFF3BBA73D3119A5800A0C95BD021642E65@barracuda.api-networks.com

I believe u missed the point. The conversion of a float to long/int should
have the same sign. There does not appear to be any reason for it
whatsoever. It just seems that there is a small set of +FP numbers that
will result in negative integers.
/gat


Rick Gorton wrote:

> 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
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list




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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-29 11:58 long->double->long goes negative Rick Gorton
2000-09-29 14:43 ` Uncle George [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-09-29 16:36 Brad Lucier
2000-09-29  7:49 Phil Carmody
2000-09-29  0:44 Uncle George
2000-09-29  4:09 ` 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
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