← Back to team overview

kicad-developers team mailing list archive

Re: Too many slices of pi.

 

----- Original Message -----

> From: Wayne Stambaugh <stambaughw@xxxxxxxxxxx>
> To: kicad-developers@xxxxxxxxxxxxxxxxxxx
> Cc: 
> Sent: Wednesday, October 17, 2012 2:21 AM
> Subject: Re: [Kicad-developers] Too many slices of pi.
> 
> I found yet another slice of pi courtesy of wxWidgets found in 
> <wx/math.h>:
> 
> #include <math.h>
> 
> #ifndef M_PI
>      #define M_PI 3.1415926535897932384626433832795
> #endif
> 
> This gets pulled in anywhere <wx/wx.h> is included which is just about 
> everywhere.  So I'm changing my proposal to removing KiCad's definition 
> of M_PI in <include/fctsys.h> and use the one in <wx/math.h> unless 
> we 
> need more precision.  I also verified that this goes back all the way 
> back to the 2.6 branch wxWidgets so we should be safe as far as that's 
> concerned.
> 
> Wayne


We won't need more precision than that. That definition from wx/math.h has far more digits than you'd need for even 80-bit IEEE 754 floats and it's about the precision of a 128-bit float; worst case is it's 2 digits short of a 128-bit float's precision.  To give you some idea of what it all means, a 128-bit fixed point format can represent the distance from Pluto to the sun in nanometers. Back here on earth we can place parts with a repeatability of a few micrometers and the cases have a manufacturing tolerance on the low end of a few tens of micrometers.  So the short story is: pick a definition, verify that it is correct, and stick to it.

- Cirilo


References