How can i get the hours from 9,633333333333333E+38 using C#?

Viewed 42

I need to convert the value 9,633333333333333E+38 (which is a double) to hours.

I've already tried to use the Timespan.FromHours() method but it actually sees the value as 96333333333333333333333333333333333333333.38 ending up with the error: "Timespan overflowed because the duration is too long".

1 Answers

A TimeSpan has a maximum value, as seen by the MaxValue field.

Console.WriteLine(TimeSpan.MaxValue);
// 10675199.02:48:05.4775807

10675199 days is about 2.562×10^8 hours. That's smaller than your 9x10^38 hours you're trying to input.

9,633333333333333E+38 hours is about 8000000000000000000000000 times the current life of the universe. Not exactly something TimeSpan was designed for.

TimeSpan doesn't look to be the tool for what you're trying to accomplish.

Related