[REBOL] Re: checksum calculation
From: rotenca:telvia:it at: 11-Sep-2003 14:39
Hi,
> ; catch math overflow
> sum: either error? try [sum + val][
> ; which way did it overflow? (positive/negative)
> either positive? sum [
> print "positive"
> ; overflowed in positive direction
> ; to-integer required because -2147483648 is by default a decimal
> (sum + to-integer -2147483648) + (val + to-integer -2147483648)
> ][
> print "negative"
> ; overflowed in negative direction
> (2147483647 + sum) + (2147483647 + val) + 2
> ]
> ][sum + val] ; no error, just add it up
> probe type? sum
> sum ]
You can use:
first sum + to pair! val
---
Ciao
Romano