From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4783 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: printf issues Date: Fri, 4 Apr 2014 11:07:05 -0400 Message-ID: <20140404150705.GN26358@brightrain.aerifal.cx> References: <20140404141515.GD3034@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1396624044 11571 80.91.229.3 (4 Apr 2014 15:07:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Apr 2014 15:07:24 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4787-gllmg-musl=m.gmane.org@lists.openwall.com Fri Apr 04 17:07:19 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WW5iA-0008Tn-Lk for gllmg-musl@plane.gmane.org; Fri, 04 Apr 2014 17:07:18 +0200 Original-Received: (qmail 28589 invoked by uid 550); 4 Apr 2014 15:07:17 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28581 invoked from network); 4 Apr 2014 15:07:17 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4783 Archived-At: 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 > > http://brightrain.aerifal.cx/~niklata/PORTING > http://www.openwall.com/lists/musl/2012/07/08/1 > > 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. Rich