From owner-freebsd-bugs Fri Oct 17 19:38:35 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id TAA23701 for bugs-outgoing; Fri, 17 Oct 1997 19:38:35 -0700 (PDT) (envelope-from owner-freebsd-bugs) Received: from shell.futuresouth.com (shell.futuresouth.com [207.141.254.20]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id TAA23696 for ; Fri, 17 Oct 1997 19:38:19 -0700 (PDT) (envelope-from fullermd@futuresouth.com) Received: from shell.futuresouth.com (mail.futuresouth.com [207.141.254.21]) by shell.futuresouth.com (8.8.5/8.8.5) with SMTP id VAA23860; Fri, 17 Oct 1997 21:37:59 -0500 (CDT) Date: Fri, 17 Oct 1997 21:37:59 -0500 (CDT) From: "Matthew D. Fuller" To: Michael Ryan cc: FreeBSD Bugs Subject: Re: Rounding up is -odd- In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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 > > --- *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* | 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 | *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*