How to get accurate float PI constant?

Hi, I’m trying to use PI as float.

I wonder if it is safe to just cast PI to float constant like below.

static_cast< float >(PI)

If I print the value, it prints 3.14159

Would this be accurate enough to use PI as float or should I create another float constant?

Thank you!

When you print a float it gets clamped by default. So what you are getting is actually not the whole number.

As of using the float cast I see no problem at all.

If you want to print the whole number check the following


1 Like

you can have a peek at the hidden digits printing (PI-3.14159)*10000

1 Like

Thank you!