Embarrassing newbie mistake
-
Once upon a time in a galaxy far, far away… When I was a new (less than 1 year) programmer and working on an IBM 1401 with no math co-processor, I noticed a program that took a long time to do percent calculations (divide). In those days a divide was a software subroutine (a.k.a. function) provided by the vendor to achieve desired results. I had the bright idea improving on it and figured that if you multiplied the numerator by 100 and then looped through a routine that subtracted the denominator you could get there faster. And it worked. Spectacularly. Until… When a numerator came through that was much larger than the denominator the machine virtually locked up. Lessons to new programmers, always test all use cases and never assume your data will be good – always assume the worst where data is concerned. Or as I heard somewhere: no matter how good the validation, some idiot will find a way to get bad data past it.
-
Once upon a time in a galaxy far, far away… When I was a new (less than 1 year) programmer and working on an IBM 1401 with no math co-processor, I noticed a program that took a long time to do percent calculations (divide). In those days a divide was a software subroutine (a.k.a. function) provided by the vendor to achieve desired results. I had the bright idea improving on it and figured that if you multiplied the numerator by 100 and then looped through a routine that subtracted the denominator you could get there faster. And it worked. Spectacularly. Until… When a numerator came through that was much larger than the denominator the machine virtually locked up. Lessons to new programmers, always test all use cases and never assume your data will be good – always assume the worst where data is concerned. Or as I heard somewhere: no matter how good the validation, some idiot will find a way to get bad data past it.
Yeah, a denominator of 0 would be quite amusing! Or a negative one. :laugh:
Latest Article:
Create a Digital Ocean Droplet for .NET Core Web API with a real SSL Certificate on a Domain -
Once upon a time in a galaxy far, far away… When I was a new (less than 1 year) programmer and working on an IBM 1401 with no math co-processor, I noticed a program that took a long time to do percent calculations (divide). In those days a divide was a software subroutine (a.k.a. function) provided by the vendor to achieve desired results. I had the bright idea improving on it and figured that if you multiplied the numerator by 100 and then looped through a routine that subtracted the denominator you could get there faster. And it worked. Spectacularly. Until… When a numerator came through that was much larger than the denominator the machine virtually locked up. Lessons to new programmers, always test all use cases and never assume your data will be good – always assume the worst where data is concerned. Or as I heard somewhere: no matter how good the validation, some idiot will find a way to get bad data past it.
You might remember that several years Intel had a problem with division with a Pentium processor. The same thing had happened - some edge cases were overlooked. That prompted them to enact a rule that the guy who writes the microcode can not write the test vectors.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
You might remember that several years Intel had a problem with division with a Pentium processor. The same thing had happened - some edge cases were overlooked. That prompted them to enact a rule that the guy who writes the microcode can not write the test vectors.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
Rick York wrote:
the guy who writes the microcode can not write the test vectors
THAT is fundamental to all testing, certainly not limited to microcode!
No, is not fundamental. It is highly recommended but not fundamental. Prior to this error Intel had not required it to be done by different people and I am certain they were not alone in that.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"