Hacker News new | ask | show | jobs
by tightbookkeeper 604 days ago
Do you prove that every line of arithmetic in your program will not overflow for all possible inputs?

Are you aware that no screen is 64k x 64k?

2 comments

> Do you prove that every line of arithmetic in your program will not overflow for all possible inputs?

If inputs come from outside, a vehement Yes!

In this particular case they wouldn't. But yes, C is a problem.
It’s a register based computer problem, not a C problem.
Not checking for overflow is a developer problem
Do you suggest branching after every operation?

a = b + c

if err { // … }

Please note that you should ensure that overflow doesn't happen, not detect when it happens. Once you let it happen, it's undefined behavior.

But you don't need to check each operation to ensure that none of them overflow. If you know that b and c are supposed to be bounded between -10 and +10, for example, the above line can't overflow. So just check that your supposition holds. In most cases, that boils down to a check on the inputs at the entry of the function.

>Are you aware that no screen is 64k x 64k?

AmigaOS, I believe from 2.0 onwards, could do that[0].

Width and Height being 16bit attributes of the struct for the requested screen.

I haven't seen an actual monitor able to display the whole thing at once, but that's fine, because you can make your screen gigantic yet set the video output to a much lower resolution.

Intuition will let you scroll through it by moving the mouse pointer past the edge.

0. http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodo...

Does this library serve Amiga developers?
If you mean intuition, it is one of the libraries included in the operating system (usually part of the kickstart ROM).

If you mean amigadev.elowar.com, it is indeed mostly referenced by Amiga developers.

libNSFB, the library being discussed and accused of being low quality because of this range assumption