3 ms·
Yeah, it was a throwaway Linqpad script on my work computer, so I can't go back and see what screwed up. I rewrote it on my Mac, which doesn't have Linqpad: us
by gwbas1c 5y ago
Yeah, it was a throwaway Linqpad script on my work computer, so I can't go back and see what screwed up. I rewrote it on my Mac, which doesn't have Linqpad:
using System;
namespace DateTime_Headroom
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine( "DateTime.MaxValue in hex: 0x" + DateTime.MaxValue.Ticks.ToString("X"));
const ulong DATETIME_RESERVED_BITS = 0xC000000000000000;
Console.WriteLine( "DateTime reserved bits in hex: 0x" + DATETIME_RESERVED_BITS.ToString("X"));
const long DATETIME_TICKS_BITS = (long)~DATETIME_RESERVED_BITS;
Console.WriteLine( "DateTime ticks bits in hex: 0x" + DATETIME_TICKS_BITS.ToString("X"));
var extraTicks = DATETIME_TICKS_BITS - DateTime.MaxValue.Ticks;
Console.WriteLine( "DateTime extra ticks in hex: 0x" + extraTicks.ToString("X"));
Console.WriteLine($"DateTime extra days: {extraTicks / TimeSpan.TicksPerDay}");
}
}
}
----
DateTime.MaxValue in hex: 0x2BCA2875F4373FFF
DateTime reserved bits in hex: 0xC000000000000000
DateTime ticks bits in hex: 0x3FFFFFFFFFFFFFFF
DateTime extra ticks in hex: 0x1435D78A0BC8C000
DateTime extra days: 1685540
Edit: Sorry about the formatting.
Also, kinda makes me wonder about the tradeoffs. I suspect that the performance advantage of 64-bit math over "bigint" math is much more useful than the risk of recompiling a program in 10,000 years to use a 128-bit date.
- kingcharles 5y agoUsername gwbas1c. Programs in C#. How about some love for VB.NET around here, huh?
- gwbas1c 5y agoI stopped at Visual Basic 6. I inherited a little bit of VB.Net back when C# was new and I honestly don't get the point of the language. A lot of the simplifications that were in classic Visual Basic just aren't in the .Net version. It was kind of useful if you really needed weak typing, but that's really a niche usage that duck typing in C# now handles.
- kingcharles 5y agoI was a C/x86 developer who switched to VB for an ASP job. Then I became a VB.NET devotee. I kept up with C# the whole time because 99% of sample code was in C# and I needed to understand it. I actually still believe VB.NET is the better language, I think it reads a lot easier and is therefore less susceptible to errors. I've given up though and switched to C# just because the support is there.