On Wed, Dec 1, 2010 at 10:40 PM, Matt Turner <matts...@gmail.com> wrote: > 1/ln(2) is equivalent to log2(e), so define it as such. > > log2(e) = ln(e)/ln(2) = 1/ln(2) > > M_PI is updated to add some precision (value found in my math.h header). > > Signed-off-by: Matt Turner <matts...@gmail.com> > --- > src/mesa/main/compiler.h | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h > index 5557a3b..4c52be2 100644 > --- a/src/mesa/main/compiler.h > +++ b/src/mesa/main/compiler.h > @@ -351,7 +351,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) > > > #ifndef M_PI > -#define M_PI (3.1415926536) > +#define M_PI (3.14159265358979323846) > #endif
Erm... just nitpicking... it may be better to define such constants using the C99 hexfloat format (e.g. the format which is generated for printf "%a"). It would avoid two issues: 1. Defining the constants in a base10 floating-point format is never 100% precise if IEEE754-style datatypes are used (which use base2) 2. (Please someone correct me if I am wrong) There is no definition what happens if the constant has more digits than fit into the datatype and the base10--->base2 conversion happens (e.g. what is used first: truncate+convert or convert+truncate). At least 128bit floating-point on SPARC with gcc4.5 and Sun Studio 12.1 deliver different results in the last two bits of the fraction part in some cases for base10 values while delivering identical results when the C99 hexfloat format is used[1]) Above in C99 hexfloat format would be (with more than enougth digits for 128bit IEEE754 floating-point :-) ): #define M_PI (0x3.243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4Ep+00) [1]=As said, I'm just nitpicking - technically 39 decimal places are enougth to estimate the circumference of any circle that fits in the (observable) universe with precision down to the the radius of an hydrogen atom. ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.ma...@nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;) _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev