# PI (Function)

*916*pages on

this wiki

## V1Edit

Indications are, `PI`

in SmileBasic V1 is identical to that in V2.

## V2Edit

The function PI() appears to return the constant 3.14135742.

The actual Pi is about 3.14159265, so I personally prefer defining my Pi manually instead of the PI() function.

If I'm right about the numbers being fixed-point with resolution 1/4096, the precise value returned is 12867/4096, about 0.0075% smaller than the true value of pi. (12868/4096 is much closer to the true value, but larger than pi, by about 0.0003%.)

It is interesting that the function `DEG`

calculates angle conversions with a value of pi which is even more precise than 1/4096 of a unit. 9100 degrees is 9100*180/pi radians, about 521391.59357; `DEG(9100)`

gives 521391.593505859375 (the closest value that can be represented in SmileBasic, an error of only about -0.00006), whereas 9100*180/(12867/4096) is about 521430.6 (39 too large). Even using the more accurate value 12868/4096 for pi, the result is 521390.11501 - almost 1.5 too small. So, the value of pi used in `DEG`

calculations is effectively more precise than can be represented as a numerical value in SmileBasic!

## V3Edit

No information on SmileBasic V3.