From owner-freebsd-arm@FreeBSD.ORG Mon Apr 12 00:42:26 2010 Return-Path: Delivered-To: freebsd-arm@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 691A9106564A; Mon, 12 Apr 2010 00:42:26 +0000 (UTC) (envelope-from maksverver@geocities.com) Received: from smtp.utwente.nl (smtp1.utsp.utwente.nl [130.89.2.8]) by mx1.freebsd.org (Postfix) with ESMTP id DCFF98FC17; Mon, 12 Apr 2010 00:42:25 +0000 (UTC) Received: from heaven.student.utwente.nl (heaven.student.utwente.nl [130.89.167.52]) by smtp.utwente.nl (8.12.10/SuSE Linux 0.7) with ESMTP id o3C0g9Y7008747; Mon, 12 Apr 2010 02:42:09 +0200 Message-ID: <4BC26C5E.7000509@geocities.com> Date: Mon, 12 Apr 2010 02:42:06 +0200 From: Maks Verver User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100322 Thunderbird/3.0.3 MIME-Version: 1.0 To: Alexander Motin References: <4BB1C5C9.8000402@FreeBSD.org> <20100330.090525.956847443318914833.imp@bsdimp.com> <4BB21B2A.6090209@FreeBSD.org> In-Reply-To: <4BB21B2A.6090209@FreeBSD.org> Content-Type: multipart/mixed; boundary="------------050601000805050903080207" X-UTwente-MailScanner-Information: Scanned by MailScanner. Contact icts.servicedesk@utwente.nl for more information. X-UTwente-MailScanner: Found to be clean X-UTwente-MailScanner-From: maksverver@geocities.com X-Spam-Status: No Cc: freebsd-arm@FreeBSD.org Subject: Re: printf(long double) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Apr 2010 00:42:26 -0000 This is a multi-part message in MIME format. --------------050601000805050903080207 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Alexander, On 03/30/10 17:39, Alexander Motin wrote: > #include int main (void) { printf("%Lf %f\n", (long > double)14.5, (double)14.5); return(0); } > > It compiles cleanly on both arm and amd64, but still not working on > arm: %./a.out 6.500000 14.500000 I investigated this in detail and it seems to be caused by a bug in the __ldtoa function that fails to account for the implicit mantissa bit of the double value (6 = 14 - 8) because the ARM port doesn't define LDBL_IMPLICIT_NBIT. Attached is a patch to lib/libc/arm/_fpmath.h that corrects this problem and also corrects the value for LDBL_MANH_SIZE. Warner, do you know if there is a subtle reason why arm/_fpmath.h contains the definitions it does now, or are these errors that should be fixed in the trunk? Kind regards, Maks Verver. --------------050601000805050903080207 Content-Type: text/plain; name="arm-longdouble.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="arm-longdouble.patch" --- lib/libc/arm/_fpmath.h.orig 2010-04-11 23:23:37.000000000 +0200 +++ lib/libc/arm/_fpmath.h 2010-04-11 23:25:48.000000000 +0200 @@ -56,8 +56,9 @@ #define LDBL_NBIT 0 #define mask_nbit_l(u) ((void)0) +#define LDBL_IMPLICIT_NBIT -#define LDBL_MANH_SIZE 32 +#define LDBL_MANH_SIZE 20 #define LDBL_MANL_SIZE 32 #define LDBL_TO_ARRAY32(u, a) do { \ --------------050601000805050903080207--