
30 Jul
2012
30 Jul
'12
4:04 p.m.
Евгений Пермяков
Can someone tell me if there are any primitives, that used to detect machine type overflows, in ghc haskell ? I perfectly understand, that I can build something based on preconditioning of variables, but this will kill any performance, if needed.
In GHC.Prim — primitives addIntC# and subIntC#:
addIntC# :: Int# -> Int# -> (#Int#, Int##) Add with carry. First member of result is (wrapped) sum; second member is 0 iff no overflow occured.
subIntC# :: Int# -> Int# -> (#Int#, Int##) Subtract with carry. First member of result is (wrapped) difference; second member is 0 iff no overflow occured.