BBS: Inland Empire Archive Date: 02-18-93 (19:34) Number: 266 From: JIM LITTLE Refer#: NONE To: HUGH MARTIN Recvd: NO Subj: Help Conf: (2) Quik_Bas
HM>DC> You learn the d*mnest things, by tinkering... HM>It's amazing how many bugs and "features" are in QB 4.5. I just ran into a HM>one converting a stats program from QB 3.0 to 4.5. Turns HM>out that QB 4.0 and above (even PDS!) can't round numbers properly. HM>According to them, CINT(30.5) = 30, but lowly QB 3.0 correctly rounds HM>up to 31. Thank you, Microsoft, for wasting another hour of my time. HM>Does VB/DOS round numbers correctly, or is this bug impervious to HM>version changes? My two cents: Some time ago, all the mathemeticians of the world got together for one of their big 'let's decide what's TRUE in the world' shing-dings and decided that rounding was not very accurate. They had already decided that if you round XX.5x, it should be rounded up, because its definitely greater than .5. However, if the number is XX.5, it's right on the 'swivel point'! What to do, what to do.. Well, it wouldn't be right to just arbitrarily round up or down ALL the time, because that would introduce an error (a small one, but an error all the same..) into the calculations (eventually). Well, these great mathematicians thought about this for a couple days, then decided that if 'x' in the number x.5 is EVEN, you round DOWN. If it's ODD, you round UP. So... 30.5 = 30 30.50001 = 31 31.5 = 32 Now, that nasty little error has been taken care of, because statistically, the chances of an even or odd number occuring are equal! Once the geniuses of the mathematical world figured this out, they finished up their conference and went home, satisfied that they had done some good in the world. <Grin> Well, obviously Microsoft decided to 'fix' the 'bug' in QB somewhere in between version 3.0 and 4.5. If you really need to round the 'old' way, I would suggest INT(number! + .5). Here to brighten your day -Jim * SLMR 2.1a * Nothing is so smiple that it can't get screwed up. $$ --- WM v2.07/91-0012 * Origin: Com-Dat BBS Hillsboro, OR. HST (503) 681-0543 (1:105/314)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET