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

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 12:59:46 +0100
MIME-Version: 1.0
In-Reply-To: <20050630.202057.83613389.haro@kgt.co.jp>
Message-ID: <SERRANOPL83mxMAKytt000002d1@SERRANO.CAM.ARTIMI.COM>

----Original Message----
>From: haro AT kgt DOT co DOT jp
>Sent: 30 June 2005 12:21

> From: "Peter J. Acklam" <pjacklam at online no>
> Date: Thu, 30 Jun 2005 13:06:51 +0200 (CEST)
>>> 
>>>> I'm seeing small bug in printf implementation.
>>> 
>>> What bug? I didn't see anything unexpected.
>>> 
>>> Peter
> 
> Hi Peter,
> 
> How come "0.125" gets printed as "0.12", and not "1.3"?
> 
> Haro


  Absolutely, there's a rounding error of some sort.  Compare the difference
when compiling the testcase with -mno-cygwin (i.e. using mingw maths lib):

dk AT mace /test/signed/lr2> cat aaa.c
#include <stdio.h>
int main(int argc, const char **argv)
{
    printf("%0.2f\n", 0.105);
    printf("%0.2f\n", 0.115);
    printf("%0.2f\n", 0.125);
    printf("%0.2f\n", 0.135);
    return 0;
}

dk AT mace /test/signed/lr2> gcc -O0 -g aaa.c -o aaa-c
dk AT mace /test/signed/lr2> ./aaa-c.exe
0.10
0.12
0.12
0.14
dk AT mace /test/signed/lr2> gcc -O0 -g -mno-cygwin aaa.c -o aaa-m
dk AT mace /test/signed/lr2> ./aaa-m.exe
0.11
0.12
0.13
0.14
dk AT mace /test/signed/lr2>


    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