取消
显示结果 
搜索替代 
您的意思是: 

error in Pi value

已解决!
转到解答

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 项奖励
1 条消息(共 22 条)
5,770 次查看

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 项奖励
2 条消息(共 22 条)
5,766 次查看

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 项奖励
3 条消息(共 22 条)
5,765 次查看

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.

4 条消息(共 22 条)
5,744 次查看

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
5 条消息(共 22 条)
5,737 次查看

*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 项奖励
6 条消息(共 22 条)
5,733 次查看

@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 项奖励
7 条消息(共 22 条)
5,726 次查看

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 项奖励
8 条消息(共 22 条)
5,725 次查看

@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.眨眼表情

9 条消息(共 22 条)
5,709 次查看

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 项奖励
10 条消息(共 22 条)
5,705 次查看