08-06-2015 02:04 PM
Multiply 8.2 by 60 (ex. converting minutes to seconds). That equals 492. Take 492 and subtract 492. Should be 0 right? Labview comes up with -5.68434. If you then take that value and subtract 1, you get -1, not -6.68434. Separately, if you subtract a constant of 492 by 492 you get the correct answer, 0. This seems like a bug, but maybe I'm crazy! This is a 2013 file, but this also happens in 2014.
08-06-2015 02:08 PM - edited 08-06-2015 02:11 PM
If you extend your numeric indicator you actually see it's "-5.68434E-14". So what you're actually seeing is rounding error. This means also, that when you subtract 1 you get -1.
If you look at all of the indicators with more sig figs, you get this:
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-06-2015 02:09 PM
NOT A BUG. This is expected behavior due to the way floating point numbers are defined (in nearly all languages, not just LabVIEW). Nonetheless, it has been reported over and over again, in various forms. Search this forum (or a Google search for "site:forums.ni.com math bug") for many, many explanations.
08-06-2015 02:09 PM - edited 08-06-2015 02:11 PM
Not a bug.
The answer is not -5.68434 but -5.68434E-14. (Make your indicator wider to see.)
This is not surprising when doing math on floating point numbers and is a very well know issue.
Please pay S-mercurio another nickel for his retirement fund.
08-06-2015 02:11 PM
It's not -5.6843, it's -568434E-14 which equals 0.0000000000000568434. Pretty close to zero. You're dealing with machine epsilon and all digital computers have this "bug". https://en.wikipedia.org/wiki/Machine_epsilon
08-06-2015 02:12 PM - edited 08-06-2015 02:12 PM
Hehehe, the number of quick responses calling out OP cracks me up
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-06-2015 02:14 PM
That's not -5.6834, it's -5.68434E-14, essentially zero. What you've demonstrated is the fact that decimal numbers don't always convert into binary floating point numbers without a small rounding error. Here's an article that explains it in depth.
Aaron T..
08-06-2015 02:18 PM
If this thread has taught me anything, it's that this forum could use a feature that tells you if a new reply has been added to the thread while you were typing out a reply of your own.
Also to watch your indicator size.
08-06-2015 02:20 PM - edited 08-06-2015 02:25 PM
@Verywiseguy wrote:
If this thread has taught me anything, it's that this forum could use a feature that tells you if a new reply has been added to the thread while you were typing out a reply of your own.
Also to watch your indicator size.
Jesus Christ, yes.
I bet you that has been suggested already, but I can't find it in the Feedback forum.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
08-06-2015 03:23 PM
I couldn't find a suggestion like this either. It's probably been mentioned somewhere but I guess it doesn't have a post of it's own? Anyway, I posted something about it in that feedback forum. Link is here.