Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , 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" To: Subject: SV: SV: Bug in printf ? Cc: In-Reply-To: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_8661_15704335.1120135537836" References: <6879888 DOT 1120133556579 DOT JavaMail DOT adm-moff AT moffice2 DOT nsc DOT no> 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--