Fable icon indicating copy to clipboard operation
Fable copied to clipboard

TimeSpan precision lost when creating big TimeSpan via another method than `FromTicks`

Open MangelMaxime opened this issue 10 months ago • 1 comments

Hello,

printfn $"""
Big TimeSpan value (Fable):            %A{System.TimeSpan.FromDays(10675199).Ticks}
Big TimeSpan value (.NET):             9223372036854775807L
"""
Big TimeSpan value (Fable):            9223371936000000000
Big TimeSpan value (.NET):             9223372036854775807L

This doesn't happens when creating TimeSpan.FromTicks because in this case we are using BigInteger.

Fixing this issues will also open the possibility improve the precision supported by TimeSpan in Fable to be on par with .NET and Python

MangelMaxime avatar Feb 19 '25 17:02 MangelMaxime

Actually, even FromTicks is affected probably because we transform from bigint to Number

printfn $"""

Big TimeSpan value (WebSharper):            %A{System.TimeSpan.FromTicks(9223372036854775807L).Ticks}
Big TimeSpan value (.NET):                  9223372036854775807L
	"""
Big TimeSpan value (WebSharper):            9223372036854769664
Big TimeSpan value (.NET):                  9223372036854775807L

MangelMaxime avatar Feb 21 '25 15:02 MangelMaxime