www.delorie.com/archives/browse.cgi | search |
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 |
Date: | Thu, 30 Jun 2005 14:45:37 +0200 (CEST) |
Message-ID: | <3600032.1120135537858.JavaMail.adm-moff@moffice2.nsc.no> |
From: | "Peter J. Acklam" <pjacklam AT online DOT no> |
To: | <cygwin AT cygwin DOT com> |
Subject: | SV: SV: Bug in printf ? |
Cc: | <pjacklam AT online DOT no> |
In-Reply-To: | <SERRANO8kxpycYGQ74C000002d5@SERRANO.CAM.ARTIMI.COM> |
Mime-Version: | 1.0 |
References: | <6879888 DOT 1120133556579 DOT JavaMail DOT adm-moff AT moffice2 DOT nsc DOT no> <SERRANO8kxpycYGQ74C000002d5 AT SERRANO DOT CAM DOT ARTIMI DOT COM> |
X-IsSubscribed: | yes |
------=_Part_8661_15704335.1120135537836 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Dave Korn wrote: > Have you considered that your sunblade might be operating > in a different rounding mode, by default? I didn't know there were different rounding modes. I thought everyone used so-called "unbiased rounding", so I'm sorry for adding confusion. > 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. Could be. I haven't dug into those matters, but your suggestion certainly makes sense. Anyway, the following line seq -4.5 1 4.5 | while read x; do printf '%4s -> %3.0f\n' $x $x; done which gives -4.5 -> -4 -3.5 -> -3 -2.5 -> -2 -1.5 -> -1 -0.5 -> -1 0.5 -> 1 1.5 -> 1 2.5 -> 2 3.5 -> 3 4.5 -> 4 suggests that printf rounds towards zero, but something funny happens for -0.5 and 0.5. Peter ------=_Part_8661_15704335.1120135537836 Content-Type: text/plain; charset=us-ascii -- 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/ ------=_Part_8661_15704335.1120135537836--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |