Error TimeSpan ..?

How is it possible that a TimeSpan with the same number of tikcs gives different TotalDays values? The following shows what I see on debuger immediately after starting my application.

Ticks: 25920000000000
TotalDays: 30.0

enter image description here

After a few clicks, when I hit a breakpoint in the same place, the values ​​look like this:

Ticks: 25920000000000
TotalDays: 29.999999999999996

enter image description here

Since I used the total number of days later, he hit me, what after his 30 and another time 29 for the “same” TimeSpan Ticks ?!

This only works on my Corei7 workstation (win7 x64) on "AnyCpu" in the .NET 3.5 Framework Configuration (on x86 it is always 30, also on 3 other workstations 29 did not happen). Any ideas?

+4
source share
1

, ( long - Ticks - double, TotalDays), "" .

int, TimeSpan.Days

TotalDays - readonly, -

return (double) this._ticks * (0.0 / 1.0);

( _ticks )

Days readonly proeprty:

return (int) (this._ticks / 864000000000L);
+1

Source: https://habr.com/ru/post/1524652/


All Articles