[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PATCH] Loop Overflow Bug Fix
- From: Paige DePol <lual@...>
- Date: Mon, 20 Nov 2017 16:03:55 -0600
Coda Highland <chighland@gmail.com> wrote:
> On Mon, Nov 20, 2017 at 1:58 PM, Paige DePol <lual@serfnet.org> wrote:
>> Coda Highland <chighland@gmail.com> wrote:
>>
>> Okay, maybe you can help answer my question Adam... how does my patch
>> change the representation of the numbers from being 2s complement for
>> integer based loops?
>>
>> From what I have read on Wikipedia, which matches what I remember from
>> my Comp-Sci classes all those years ago, 2s complement is a way that
>> most modern processors internally represent integers. How does changing
>> the loop logic to prevent an overflow affect this representation?
>>
>> Thanks for any insight, it is appreciated!
>>
>> ~Paige
>
> I mean, from a technical perspective, it doesn't stop being 2s
> complement in the internal representation. But one of the things about
> dealing with 2s complement arithmetic is the concept of overflow --
> the entire concept of 2s complement only works if you've got fixed
> width values that can overflow.
>
> And your patch fixes one of the ways it can overflow, bringing it
> closer to the behavior of non-integer loops.
>
> According to the reference manual, for loops already pay attention to
> the sign of the step, so you couldn't write a loop that DEPENDS on the
> overflow behavior anyway -- if you tried to write "for i = 1, -1,
> 1000000" in hopes of overflowing the integer and coming back up from
> below, it wouldn't work.
>
> So while the internal representation is still 2s complement, the
> checks and fixes keep it from ACTING like 2s complement arithmetic.
Okay, I understand. I was just stuck looking at the issue from the
technical perspective. Thank you for taking the time to explain it!
As scripting languages are used by people with quite a wide variety of
coding ability, I think it is nice when the language can catch simple
edge cases for the coder, especially if they have minima impact on the
execution of scripts.
I would also like it if 2.5,3.0,0.1 actually iterated on 3.0, but that
sure seems to be quite the complex problem in general.
~Paige
- References:
- [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, dyngeccetor8
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Roberto Ierusalimschy
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Roberto Ierusalimschy
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Dirk Laurie
- Re: [PATCH] Loop Overflow Bug Fix, Hisham
- Re: [PATCH] Loop Overflow Bug Fix, Coda Highland
- Re: [PATCH] Loop Overflow Bug Fix, KHMan
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, KHMan
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, KHMan
- Re: [PATCH] Loop Overflow Bug Fix, Coda Highland
- Re: [PATCH] Loop Overflow Bug Fix, Paige DePol
- Re: [PATCH] Loop Overflow Bug Fix, Coda Highland