bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: small fix for lib/sh/snprintf.c


From: Petr Sumbera
Subject: Re: small fix for lib/sh/snprintf.c
Date: Mon, 16 Apr 2012 10:30:45 +0200
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9.2.13) Gecko/20110117 Lightning/1.0b2 Thunderbird/3.1.7

I have found one more problem:

I'm getting following:
bash -c 'printf "x%+fx\n" -0'
x+0.000000x

where it should be:
x-0.000000x

This is cause by:

/* round off to the precision */
#define ROUND(d, p) \
            (d < 0.) ? \
             d - pow_10(-(p)->precision) * 0.5 : \
             d + pow_10(-(p)->precision) * 0.5

where (-0 < 0.) isn't true.

And there is probably no easy solution for this:

http://en.wikipedia.org/wiki/Signed_zero

Thanks,

Petr

On 04/16/12 01:14 AM, Chet Ramey wrote:
On 4/13/12 9:57 AM, Petr Sumbera wrote:
On 04/13/12 03:18 PM, Petr Sumbera wrote:

Problem 2:
==========

bash -c 'printf "x%+010.0fx\n" 123'
x000000+123x

where it should be:
x+000000123x

Fixed in chunk #3 (but the problem is there also for other types!).

My fix breaks following case:

Thanks, the patches are very helpful.

Chet




reply via email to

[Prev in Thread] Current Thread [Next in Thread]