Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Nov 2008 22:02:30 +0100
From:      Andreas Tobler <andreast-list@fgznet.ch>
To:        Peter Grehan <grehan@freebsd.org>
Cc:        FreeBSD PowerPC ML <freebsd-ppc@freebsd.org>
Subject:   Re: ppc float.h
Message-ID:  <491DE766.8040705@fgznet.ch>
In-Reply-To: <491C7C47.8080803@fgznet.ch>
References:  <20081113105926.ELO26264@dommail.onthenet.com.au> <491C7C47.8080803@fgznet.ch>

index | next in thread | previous in thread | raw e-mail

Hi Peter,

Andreas Tobler wrote:
> Peter Grehan wrote:
> 
>>> can somebody explain why we have these defines in 
>>> sys/powerpc/include/float.h ?
>>
>>  Have a look at
>>
>> http://svn.freebsd.org/viewvc/base?view=revision&revision=132421
> 
> Hm, meanwhile OS-X has 128-bit long double...
> 
>>  Basically, the ABI was switched from 128 bit long doubles to
>> 64. Not exactly SVR4 compliant but then no-one else is.
> 
> And there is no need to go back to 128-bit? No benefit?
> What would have to be done? Libc? I know the compiler issue.
> Would this break too much?

Coming back to myself. Doesn't matter if going to 128-bit long double or 
not. The LDBL_MIN/MAX/EPSILON definitions in float.h are wrong.

If you do a printf ("%Lf\n", LDBL_EPSILON); you run into a compiler warning:

warning: format '%Lf' expects type 'long double', but argument 2 has 
type 'double'

So to fix that I propose the appended patch.

Thanks,
Andreas

P.S, making the compiler work with 128-bit long-double is still possible.

[wolfram:~] andreast% diff -u float.h~ float.h
--- float.h~	2008-11-14 21:31:00.000000000 +0100
+++ float.h	2008-11-14 21:32:07.000000000 +0100
@@ -72,13 +72,13 @@
  #define DBL_MAX_10_EXP	308

  #define LDBL_MANT_DIG	DBL_MANT_DIG
-#define LDBL_EPSILON	DBL_EPSILON
+#define LDBL_EPSILON	2.2204460492503131e-16L
  #define LDBL_DIG	DBL_DIG
  #define LDBL_MIN_EXP	DBL_MIN_EXP
-#define LDBL_MIN	DBL_MIN
+#define LDBL_MIN	2.2250738585072014e-308L
  #define LDBL_MIN_10_EXP	DBL_MIN_10_EXP
  #define LDBL_MAX_EXP	DBL_MAX_EXP
-#define LDBL_MAX	DBL_MAX
+#define LDBL_MAX	1.7976931348623157e+308L
  #define LDBL_MAX_10_EXP	DBL_MAX_10_EXP

  #endif /* _MACHINE_FLOAT_H_ */





home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?491DE766.8040705>