Am Fri, 21 Nov 2014 11:41:55 -0800 schrieb "H. S. Teoh via Digitalmars-d" <digitalmars-d@puremagic.com>:
> On Fri, Nov 21, 2014 at 10:57:44AM -0800, Walter Bright via Digitalmars-d > wrote: > > On 11/21/2014 10:05 AM, ketmar via Digitalmars-d wrote: > > >why do you believe that i'm not aware of overflows and don't checking > > >for that? i'm used to think about overflows and do overflow checking > > >in production code since my Z80 days. and i don't believe that > > >"infrequent bug" is better than "frequent bug". both are equally bad. > > > > > > Having coded with 16 bit computers for decades, one gets used to > > thinking about and dealing with overflows :-) > > I used to write 8-bit assembly code on the 6502 (yeah I'm so dating > myself), where overflows and underflows happen ALL THE TIME. :-) In > fact, they happen so much, that I learned to embrace modulo arithmetic > instead of fearing it. I would take advantage of value wrapping to shave > off a few cycles here and a few cycles there -- they do add up, given > that the CPU only ran at a meager 1MHz, so every little bit counts. > > Then in the 16-bit days, I wrote a sliding-window buffer using a 64kB > buffer where the wraparound of the 16-bit index variable was a feature > rather than a bug. :-) Basically, once it reaches within a certain > distance from the end of the window, the next 32kB block of data was > paged in from disk into the other half of the buffer, so as long as the > operation didn't span more than 32kB each time, you can just increment > the 16-bit index without needing to check for the end of the buffer -- > it'd automatically wrap around to the beginning where the new 32kB block > has been loaded once you go past the end. A truly circular buffer! :-P > > > T I used to be a kid playing a GameBoy game called Mystic Quest (which some in Asia may know it as part of the Final Fantasy franchise). One day I got really greedy and spend days collecting gold. Vast amounts of gold. I learned which enemies drop the most and soon got 10000, 20000, 30000, 40000, 50000, 60000, ... NOOOOOOOOOOO! That game taught me two things. That Dodos are extinct and not checking for overflows is a painful experience. -- Marco