Sujet : Re: More Funny Stuff From Joel
De : bowman (at) *nospam* montana.com (rbowman)
Groupes : comp.os.linux.advocacyDate : 17. Jun 2024, 06:25:50
Autres entêtes
Message-ID : <ld9s6dFj37eU1@mid.individual.net>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Pan/0.149 (Bellevue; 4c157ba)
On Sun, 16 Jun 2024 18:47:00 -0500, chrisv wrote:
Believe it or not, I realize that some software "bugs" get past warnings
and errors and testing, and make it into "released" code!
I fixed a three year old bug last week that didn't throw warnings and made
it past testing.
if (x != last_x && y != last_y) {
do some initialization
}
The intent was to avoid an expensive PIP search if the passed in x/y
matched the previous search. There is nothing syntactically wrong with
the statement and it avoided the duplication on the same address x/y. An
address with a different x/y would be initialized. However, if you ran two
addresses with the same y back to back the second address would return the
polygon information for the first. With three years and who knows how many
addresses on multiple sites, I'd give it at least a one in a million.
I've fixed bugs that were over 20 years old. Bad implementation, but
nothing a compiler would pick up and a very limited number of edge cases
that would trigger the bug.
Back at Lunar Lander:
https://www.technologizer.com/2009/07/19/lunar-lander/I downloaded the Vintage BASIC package and the 1969 version and it does
run. For kicks I decided to do a Python version. I forgot how hideous
BASIC was. A snippet:
140 A=120:V=1:M=33000:N=16500:G=1E-03:Z=1.8
150 PRINT L,INT(A);INT(5280*(A-INT(A))),3600*V,M-N,:INPUT K:T=10
160 IF M-N<1E-03 THEN 240
170 IF T<1E-03 THEN 150
180 S=T: IF M>=N+S*K THEN 200
190 S=(M-N)/K
200 GOSUB 420: IF I<=O THEN 340
210 IF V<=0 THEN 230
220 IF J<0 THEN 370
230 GOSUB 330: GOTO 160
240 PRINT "FUEL OUT AT";L;"SECONDS":S=(-V+SQR(V*V+2*A*G))/G
...........
420 Q=S*K/M: J=V+G*S+Z*(-Q-Q*Q/2-Q^3/3-Q^4/4-Q^5/5)
430 I=A-G*S*S/2-V*S+Z*S*(Q/2+Q^2/6+Q^3/12+Q^4/20+Q^5/30):RETURN
At least there are no computed GOTOs. I forget if BASIC had those or if it
was a FORTRAN thing. If you're really perverted you can set up an array of
function pointers in C to do it.
This should be right up Dufus' line with all the math. Meanwhile I may try
to figure out what the hell it's doing. I don't know if this version has
the divide by 2 bug or not. Spreading out the polynomial might help. For
added obfuscation 420 has Q*Q and 430 has Q^2.