LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rounding error in timestamps

Solved!
Go to solution

MJulien_0-1706204958583.png

In the image above, I display the same number 4 times. Numeric is a DBL, TimeStamp is a timestamp 😊. Which displays 4 digits of precision, the "2" indicators display 7 digits of precision. And you can see that the "Time Stamp" displays a 6 where it should display a 7.
I think there's a display bug, unless I'm wrong. As it is, it doesn't particularly bother me, but in principle it's mathematically wrong and therefore serious (if you take into account the rounded value on the display, the number is always correct.

I've seen this bug on a particular value, I haven't tried it with other values. I'm using LabVIEW 2019.
If I'm not mistaken, I think it's necessary to find out, and even to send it back to NI for the bug to be corrected, unless it's already been corrected.

Julien
0 Kudos
Message 1 of 11
(1,528 Views)

How did you even get the time stamp control to look like that?

 

When you put one down by default it looks like this:

Kyle97330_0-1706219378777.png

 

I'm assuming you have some sort of custom formatting set up... what's the format string being used?

0 Kudos
Message 2 of 11
(1,488 Views)

Hi,

basic display format customization :

MJulien_0-1706260854650.png

Timestamp display bug.png

 

Julien
Message 3 of 11
(1,466 Views)

Frankly I don't understand what you are doing here but....

 

The numeric control is rounding and the timestamp control is not.

 

I don't think this is a bug because:

 

Whether you want a numeric control or indicator to round is debatable but you would never want a timestamp to be rounded.

========================
=== Engineer Ambiguously ===
========================
Message 4 of 11
(1,409 Views)

When I display a number or a timestamp on the screen, it's not to display all the possible decimals, I display what's necessary. So OK, the example shown was in µs, which isn't much (but on a MIL-STD-1553 bus it counts). But it's valid with only one decimals:

MJulien_0-1706295005532.png

 

It's the same number, and whether it's displayed in a DBL or Timestamp datatype indicator, displayed in "relative time" or "absolute time" format doesn't round it off correctly: it seems to me that it's mathematically wrong.
Of course, if you take the variable and use it to make calculations, they will be correct because the display format is only for display purposes; but when I'm in front of my screen I only see what's displayed, so in this case I'm seeing a false value.
When you look at your watch and you see 8:59 and you've got an appointment at 8, do you say to yourself that it's still 8, so I'm on time for my appointment? (as I'm a specialist in being late, the next time I'm late I'll say: "hey, it's a timestamp, I don't want to round it up 😊").

Julien
0 Kudos
Message 5 of 11
(1,398 Views)

Rounding up a current timestamp would display a time that's actually in the future. Nobody can predict the future. 🙂

0 Kudos
Message 6 of 11
(1,378 Views)

Your analogy somehow is flawed,.if arriving at 8:59 is 59 minutes to late for the appointment you should have in the first place shown the timestamp with minutes too. Or would 8:29 be perfectly on time in your example? 😀

 

The shown precision is important and something you as designer need to decide. If minutes are important you need to display them. Typically you display numerics with one decimal more than what is required by the task at hand. Ok some people like to display their numbers always with 6 digits after the decimal point simply because they can, thinking “more is better”.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 11
(1,356 Views)

Timestamps are not doubles. They are a distinct data type.

 

https://www.ni.com/en/support/documentation/supplemental/08/labview-timestamp-overview.html

 


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 8 of 11
(1,257 Views)

@M.Julien wrote:

 

MJulien_0-1706295005532.png


The things said here are true, but it still feels as if the examples shown here should show 46.7 (certainly for the second one, where it's relative time and not a timestamp). It seems like the behavior is to always floor when showing one of the time formats.

 

Does anyone have a good suggestion for why the displayed behavior would be correct? Altenbach's tongue in cheek remark about not getting times which haven't happened yet could possibly be a reasonable explanation.


___________________
Try to take over the world!
0 Kudos
Message 9 of 11
(1,211 Views)

@tst wrote:

@M.Julien wrote:

 

MJulien_0-1706295005532.png 


The things said here are true, but it still feels as if the examples shown here should show 46.7 (certainly for the second one, where it's relative time and not a timestamp). It seems like the behavior is to always floor when showing one of the time formats.

 

Does anyone have a good suggestion for why the displayed behavior would be correct? Altenbach's tongue in cheek remark about not getting times which haven't happened yet could possibly be a reasonable explanation.


My best guess is incompetence.  A lot of people who write code aren't very good at it.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 10 of 11
(1,194 Views)