On 05-05-2012 07:32, Era Scarecrow wrote:
On Saturday, 5 May 2012 at 04:57:48 UTC, Alex Rønne Petersen wrote:
Hi,

I don't think the language really makes it clear whether overflows and
underflows are well-defined. Do we guarantee that for any integral
type T, T.max + 1 == T.min and T.min - 1 == T.max?

This is relevant in particular for GDC and LDC since they target a lot
of weird architectures.

Any systems that implement a carry flag likely works exactly like that.
Carry flag is set or cleared after a math operation, allowing you to
extend the size of your integer any level you want, like in oh the 6502?

Might look something like this: Been a while but you should get the idea

clc ;clear carry
loop_here:
mov ax, [bx]
adc [dx], ax
inc bx
inc dx
dec cx
cmp cx, 0
jne loop_here

;if carry after this point then...
jc overflow_warning


Right, but the question was whether the language guarantees what I described. C and C++ don't, and IMO, we should strive to fix that.

--
- Alex

Reply via email to