[Haskell-cafe] Detecting numeric overflows
permeakra at gmail.com
Mon Jul 30 22:43:53 CEST 2012
On 07/31/2012 12:04 AM, Artyom Kazak wrote:
> Евгений Пермяков <permeakra at gmail.com> писал в своём письме Mon, 30
> Jul 2012 09:47:48 +0300:
>> 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.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
Still no way to detect overflow in *.
Strangely enough, I found some relevant descriptions in *.pp in dev
branch, so I expect them in 7.6.1. They applies to native-size Word and
More information about the Haskell-Cafe