Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 4 Apr 2014 11:07:05 -0400
From: Rich Felker <>
Subject: Re: printf issues

On Fri, Apr 04, 2014 at 10:35:00AM -0400, Morten Welinder wrote:
> > before you can mock libc code you need to educate yourself
> I did and that's why I called the code "cute", not "wrong".  But if you read
> the porting documentation
> you will notice that nowhere does it warn that defining LDBL_MANT_DIG
> as anything but a base-10 constant may cause printf-rounding to fail.

Good point.

> > Do you have any ideas for a clean way to avoid this
> > assumption without having to compute the value at runtime?
> I don't know if ldexpl will get constant folded by the compiler, but if not,
> I think (2.0L/LDBL_EPSILON) ought to work as a replacement.  It's not
> as likely to get prices at the obfuscated C contents, though.

Thanks, I think that's exactly the right solution. FWIW, I _would_
like this code to be easily adaptable for use outside libc if somebody
wants it, so eliminating implementation-internal assumptions like this
is nice.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.