Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: Tony Hammitt <thammitt@kc.rr.com>
Subject: Re: floor() broken on Multia
Date: 2000/03/03	[thread overview]
Message-ID: <38BFFE80.3C86D283@kc.rr.com> (raw)
In-Reply-To: 89npn4$ddt$1@hyperion.triode.net.au

Someone emailed me and said that the given kludge has problems
with accuracy and overflow, which is kinda obvious once I think
about it.

You obviously have to limit the input range to +/-2^31 and it
would be better to subtract something less than one for the
negative case, so make it:

y = (double)(int)((x<0)?x-0.999999999999:x);

Sorry about the mixup, it was 1am after all...

Tony

telford@xenon.triode.net.au wrote:
> 
> Tony Hammitt <thammitt@kc.rr.com> wrote:
> > This isn't pretty, but it works:
> 
> > y=floor(x); is equivalent to y=(double)(int)((x<0)?x-1:x);
> 
> OK, thanks for that it seems to work without hanging since
> it doesn't use the troublesome instruction. Worst case I can patch
> the libc source and recompile everything (yuck). This is especially
> annoying since I found that the X11 server contains the same bad
> instructions and recompiling that is a big undertaking on a Multia.
> 
> I'm trying a newer kernel...
> 
>         - Tel



  reply	other threads:[~2000-03-03  5:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-02  5:00 floor() broken on Multia telford
2000-03-03  5:00 ` Ryan C. Price
2000-03-03  5:00   ` Michal Jaegermann
2000-03-06  5:00     ` telford
2000-03-03  5:00 ` Tony Hammitt
2000-03-03  5:00   ` telford
2000-03-03  5:00     ` Tony Hammitt [this message]
2000-03-06  5:00       ` Ryan C. Price
2000-03-03  5:00 ` telford
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