PI versus M_PI

Hola a todos: Hi everyone

¿Cuál es la diferencia entre PI y M_PI? Could someone tell the difference between PI and M_PI?

Gracias Thanks in advance

Where did you see M_PI?

AVR libc math.h includes:

define M_PI 3.141592653589793238462643

Arduino core wiring.h includes:

define PI 3.1415926535897932384626433832795

(Note: AVR gcc 'double' and 'float' types are the same and only good for about 6 digits of accuracy so it really doesn't matter.)

Thanks, john

So, M_PI is included in Arduino software or libraries and it is not necessary declare it as a variable, isn' t it?

LMSimarroG:
So, M_PI is included in Arduino software or libraries and it is not necessary declare it as a variable, isn’ t it?

Not only is it not necessary, it is not possible.

In Java, Math.PI is formally defined as "that floating point value which is closer to PI than any other". I imagine the AVR library is similar. PI has some extra digits after the 24th place, with is one in one septillion. That is, if PI was stretched out to 314,000 km (Pi*1e14 m), which is nearly the distance to the moon (384,400 km) the difference between PI and M_PI would be less than the width of a hydrogen atom (1e-10m).

I don't think its anything anyone needs to worry about.

@PaulMurrayCbr: aw, crap. I'm not going to be able to sleep tonight!

M_PI is an unixism. It is a pretty standard define, though it is not in standard C.