You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's because fromInteger(used for the literal 42) and fromRational(used for the literal 42.0) produce very different results when the input is out of range:
martijnbastiaan
changed the title
Fixed: fromInteger and fromRational don't saturate (correctly)
Clash.Sized.Fixed: fromInteger and fromRational don't saturate correctly
Oct 11, 2018
fromInteger does not know anything about its underlying representation, so unless we convert res back to an integer and compare it to the original input I'm not sure how we can fix this.
Needs `-XNegativeLiterals` to fully saturate to `minBound`,
because without that extension `-42` is desugared to
`negate (fromInteger 42)`, and `-42.0` is desugared to
`negate (fromRational (42 % 1))`. Which means it's first
saturated to the upper bound and then negated.
Fixes#374
Needs `-XNegativeLiterals` to fully saturate to `minBound`,
because without that extension `-42` is desugared to
`negate (fromInteger 42)`, and `-42.0` is desugared to
`negate (fromRational (42 % 1))`. Which means it's first
saturated to the upper bound and then negated.
Fixes#374
Needs `-XNegativeLiterals` to fully saturate to `minBound`,
because without that extension `-42` is desugared to
`negate (fromInteger 42)`, and `-42.0` is desugared to
`negate (fromRational (42 % 1))`. Which means it's first
saturated to the upper bound and then negated.
Fixes#374
While looking at Ben's on fix for signum Fixed: c2d064f
I noticed that even with that fix:
It's because
fromInteger
(used for the literal42
) andfromRational
(used for the literal42.0
) produce very different results when the input is out of range:But our documentation states that Fixed saturates, so both of these should produces 3 times the same tuple:
The text was updated successfully, but these errors were encountered: