"QPirate" was debugging an issue with purchase order version information. The format was supposed to be "Revision#.Version#", essentially "major" and "minor" versions for the various steps as the purchase order wormed its way through the company's incredibly complicated purchasing process.
Unfortunately, that isn't what was happening. Many numbers behaved in unexpected ways when they were versioned too many times. QPirate dug in, and found this:
double PRVN = Convert.ToDouble(dr.PoRevNumber) + (Convert.ToDouble(dr.POVerNumber) / 10);
In a reverse of the usual problem of stringly typed information, here we try and represent what should be strings as doubles, and there lies the root of our problem. POVerNumber
gets divided by 10, which if you only have 9 versions, that's fine- but as soon as you have ten or more, your POVerNumber
starts getting added to your PoRevNumber
.
The fields were actually strings to begin with, which adds insult to injury. They had to convert them to doubles to do this arithmetically challenged solution to version numbers, instead of just doing some string concatenation.
For bonus points, I really enjoy the inconsistent capitalization of PO
.