LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

error in Pi value

Solved!
Go to solution

Discovered a bug in the labVIEW constant for Pi.

Actual value 3.14159265358979323846 according to a number of sites (http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html), 

 

LabVIEW value for Pi when indicator is set to 25  digits of precision ((only shows up to 16 decimal points which is probably the limit) : 3.1415926535897931

 

The last digit should stay rounded at 2, and if the precision went one more, then we would see the 3 round up to 4 because of the 8.

 

 

This causes issues believe it or not when solving some equations, it took us awhile to find it.

 

 

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 1 of 22
(4,124 Views)

Hi eximo,

 

is this issue maybe related to the limited accuracy of floating point numbers?

Which numeric representation do you use?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(4,120 Views)

That's a limitation of double precision numbers. There is no way to represent 3.1415926535897932 as a double precision number.

 

You can try using extended precision numbers.

0 Kudos
Message 3 of 22
(4,119 Views)

LabVIEW help for pi constant says 3.1415926535897932.  If it can't be represented properly at double precision, NI shouldn't be storing it as such.  I'd call that a bug.

Message 4 of 22
(4,098 Views)

Hi mancho,

 

why should it be called a bug when you get the best DBL you can get for pi? You can switch the pi constant to SGL or EXT...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 22
(4,091 Views)

*Sigh* Pi to two decimal places is good enough to insert a probe into orbit around Jupiter.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 22
(4,087 Views)

@GerdW wrote:

Hi mancho,

 

.... You can switch the pi constant to SGL or EXT...


I didn't even know you could change representation of constants.  That's interesting.  Thanks.

0 Kudos
Message 7 of 22
(4,080 Views)

To answer GerdW , I'm using extended precision.  For my system, it allows for ~17 digits of precision. 

-Regards

eximo
_______________________________________________
UofL Bioengineering M.S.
Neuronetrix

"I had rather be right than be president" -Henry Clay
0 Kudos
Message 8 of 22
(4,079 Views)

@billko wrote:

*Sigh* Pi to two decimal places is good enough to insert a probe into orbit around Jupiter.


Yes, but you may prefer more precision if they put a probe in Uranus.Smiley Wink

Message 9 of 22
(4,063 Views)

This is strange!  If you change the Pi constant to extended precision and wire it to an Extended indicator, you get the correct "2" digit at position 16 (but can't display additional numbers).  It does look like going to Extended (at least for Pi) can get you another decimal digit ...  Weird.  I'm not sure whether to call this a Bug or a Feature.

 

Bob Schor

0 Kudos
Message 10 of 22
(4,059 Views)