Problem: The function toNum transforms an object of the type
Time timeunit to a value of the type that satisfies the Num
constraint. However, the former object can contain a fractional value
inside, which then needs to get floored before being converted to a
Num value. This could lead to a possible loss of precision.
Solution: Create a separate function that converts the Time objects
losslessly to a value of the type that satisfies a stricter constraint:
Fractional. The lossless conversion can be done via fromRational.
Problem: The function
toNum
transforms an object of the typeTime timeunit
to a value of the type that satisfies theNum
constraint. However, the former object can contain a fractional value inside, which then needs to get floored before being converted to aNum
value. This could lead to a possible loss of precision.Solution: Create a separate function that converts the
Time
objects losslessly to a value of the type that satisfies a stricter constraint:Fractional
. The lossless conversion can be done viafromRational
.Fixes #124 Fixes #130