[Mesa-dev] [PATCH] Improve ONE_DIV_LN2 and M_PI constants

Ian Romanick idr at freedesktop.org
Wed Dec 1 15:26:47 PST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 12/01/2010 02:45 PM, Roland Mainz wrote:
> On Wed, Dec 1, 2010 at 10:40 PM, Matt Turner <mattst88 at 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 <mattst88 at 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").

That is probably true.  However, I think the only cases where we need
our own definitions of these constants are the same cases where the
hexfloat format is not supported.  Add it to the long list of useful C99
features that we can't use. :(  As far as I'm aware, Visual Studio does
not support hexfloat.  Nor do the AIX C compiler or the VMS C compiler.
 I'm sure there are a few other weird C89 compilers that core Mesa
intends to support that don't do this feature.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz22bUACgkQX1gOwKyEAw+ZZACdFY4Lxb173BHqYwEEUBaySkdw
8T8AnRy/tnXGRG1CwtI3uYZ75jWDGgHx
=qZRk
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list