[M3devel] integer overflow and for loops
Jay K
jay.krell at cornell.edu
Wed Jan 13 22:58:55 CET 2010
I believe it is the same thing. As long as you still compute the lower bits correctly.
There should also be carry in.
And check if the arithmetic library doesn't already provide this stuff.
You might also provide a library, where, at least for add/sub, signed and unsigned
operations are merged but two extra bits are output: "signed overflow" and "unsigned overflow".
Probably all processors do that in one add/sub instruction that produces at least
2 status flags.
"signed overflow" is the "second to last carry bit" as I recall.
"unsigned overflow" is merely the "last carry bit".
Another way to look at it is that there is signed overflow if there was
carry into the sign bit.
Another implementation choice is what lower bits to return if there is overflow.
I had a "new idea" that you might as well just always use the direct
implementation to compute the lower bits. It's a little extra work
in the highest precision multiplication case but probably ok.
That is -- look at hand.c, how m3_mult_u64 throws away the
result of the last m3_add_u64.
Someone should also write a bunch of code with these things and then
argue for operator overloading in the language. :)
- Jay
> Date: Wed, 13 Jan 2010 09:25:14 -0500
> From: hendrik at topoi.pooq.com
> To: m3devel at elegosoft.com
> Subject: Re: [M3devel] integer overflow and for loops
>
> On Wed, Jan 13, 2010 at 03:08:47AM +0000, Jay K wrote:
> >
> >
> > INTERFACE IntegerOverflowOut;
>
> While we're at it, should there be a carry out as well?
>
> -- hendrik
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100113/1cc7e05e/attachment-0002.html>
More information about the M3devel
mailing list