delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/30/08:32:18

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: SV: Bug in printf ?
Date: Thu, 30 Jun 2005 13:29:56 +0100
MIME-Version: 1.0
In-Reply-To: <6879888.1120133556579.JavaMail.adm-moff@moffice2.nsc.no>
Message-ID: <SERRANO8kxpycYGQ74C000002d5@SERRANO.CAM.ARTIMI.COM>

----Original Message----
>From: Peter J. Acklam
>Sent: 30 June 2005 13:13

> Dave Korn [dave DOT korn AT NONONOATHOUSANDTIMESNO] wrote:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  http://cygwin.com/acronyms#PCYMTNQREAIYR please!  TIA!

> 
>> haro AT OOPSNOTAGAIN wrote:
>> 
>>> How come "0.125" gets printed as "0.12", and not "1.3"?
>> 
>> Absolutely, there's a rounding error of some sort.
> 
> For what it's worth: My Sunblade 100 running Solaris 9 has
> Solaris' /bin/printf and GNU's printf as /usr/local/bin/printf
> and both give "0.12", not "0.13".
> 
> I am quite sure it is the printf returning "0.13" that is buggy.

  Have you considered that your sunblade might be operating in a different
rounding mode, by default?

> Note that the value "0.125" can be represented exactly with IEEE
> double precision arithmetic, so inexact representation is not the
> matter here.

  I never suggested it was.  Nonetheless, I would imagine that printf may
well work under-the-hood by shifting the desired decimal places above the
point, rounding to integer, and printing out that number.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019