Date: Fri, 17 Oct 1997 21:37:59 -0500 (CDT) From: "Matthew D. Fuller" <fullermd@futuresouth.com> To: Michael Ryan <mike@NetworX.ie> Cc: FreeBSD Bugs <bugs@FreeBSD.ORG> Subject: Re: Rounding up is -odd- Message-ID: <Pine.BSF.3.96.971017213556.23821A-100000@shell.futuresouth.com> In-Reply-To: <ECS9710180021A@NetworX.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 18 Oct 1997, Michael Ryan wrote: > Howdy, > > Why does > printf "%1.2f\n" 7.005 > produce > 7.00 > while > printf "%1.2f\n" 8.005 > produces > 8.01 > ? > > Number from 8.005 to 15.005 and 32.005 to 62.005 round up, > while others in this range don't! Just as a guess, look at the way floats are stored in terms of bit locations. I'm a bit rusty on this, but it seems to me that it has to do with the placement of where the .005 falls relative to a byte boundary. The way it's happening at powers of 2 (8, 16, 32, etc.) seem to amplify this. Sounds like an ANSI spec thing, not FreeBSD specifically. Can you verify whether this happens under other OS's too? > Bye, > Mike > <mike@NetworX.ie> > --- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | FreeBSD; the way computers were meant to be | * "The only reason I'm burning my candle at both ends, is * | that I haven't figured out how to light the middle yet."| * fullermd@futuresouth.com :-} MAtthew Fuller * | http://keystone.westminster.edu/~fullermd | *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971017213556.23821A-100000>