Pet Bugs?
benreece asks: "During my few years as a programmer/developer I've come across some strange bugs. Recently I found that Microsoft's VB/VBScript(ASP) round function has problems (for example, 'round(82.845)' returns '82.84' instead of '82.85'). It took me an annoyingly long time to realize the problem wasn't mine. I'm wondering what other obscure, weird, and especially annoying bugs in languages/compilers/etc have frustrated other developers." Memorable bugs. Every developer has one. What were yours?
Round to the nearest even digit if the truncated value is .5 Otherwise there's a slight upward bias.
Infuriate left and right
Floating point numbers have problems with precision, your computer can not store 82.845 in a floating point number so the number it stores is slightly less than 82.845 which VB correctly rounds to 82.84
"When you convert a decimal value to an integer value, VBA rounds the number to an integer value. How it rounds depends on the value of the digit immediately to the right of the decimal place--digits less than 5 are rounded down, while digits greater than 5 are rounded up. If the digit is 5, then it's rounded down if the digit immediately to the left of the decimal place is even, and up if it's odd. When the digit to be rounded is a 5, the result is always an even integer." so, Ed is correct...the round function is working to the documentation...
"Facts are meaningless. You could use facts to prove anything that's even remotely true." - Homer Simpson
This was on NT.
;-).
While exiting the program, Microsft
was unloading the socket DLL before DLL's we had
created. This caused our program to always crash
on exit.
It was obvious due to some internal DLL dependencies,
NT was choosing a random order
to unload DLLs.
We spent months trying to fight with Microsoft,
but could not get a solution. In the end
we decided not to support NT as a platform
That's not a bug. It's a more accurate way to round off numbers. If you always round 5 up, that means you round 5 out of 9 numbers up, and 4 out of 9 numbers down. This can cause problems if you're rounding lots of numbers.
NO!!!!!!
Please don't take this as a flame, because I'm not upset with you, just the ignoramuses that came up with this scheme. This is a stupid way define ROUND(), and I disagree entirely with the justifiction because ROUND() has to be defined in the case that the digit is a zero, right?
In other words,
digits 0,1,2,3,4 get rounded DOWN
digits 5,6,7,8,9 get rounded UP
See - it's completely even without this odd/even cockamamie bullstuff. In fact, this definition of ROUND() throws off the statistics because it inappropriately weights the UP/DOWN results (either 50/50 or 60/40) based on info that is irrelevant to the ROUND() process.
It's like the people who coded this function never studied actual math and don't understand that the trivial case (zero) counts!
I'm sorry, I don't usually go off like this but when something this simple gets this fscked up, it really frosts my wheaties.
"Lawyers are for sucks."
- Doug McKenzie
One of my all time favorites. Just print too many backspaces and cause the window's machine to croak. Always a crowd pleaser. And the funny thing is it still works today in NT/XP ...
Good details here
Yes but every time I try to see it your way, I get a headache.
http://support.microsoft.com/default.aspx?scid=kb; EN-US;q240015
Now, I wasted a lot of time, but eventually confirmed on the web that this is a known bug in the Microsoft C++ library which has persisted from Visual Studio 5 into version 6.
Apparently, the Standard C++ Library used in both products was produced by Dinkumware and they, with their illustrious author/founder P. J. Plauger, were embroiled in a multi-year copyright dispute which made it impossible for them to debug (let alone update) the library. Most of the commenters online seemed to believe that this problem could not be solved and we had to wait for the copyright battle to be resolved (it has).
My impression is that Microsoft has elected not to provide an update to the library (which includes the STL) until the release of .NET.
Karma: Bored. (Thinking about resurrecting the "Anyone else is an imposter" joke.)
Will fix that for you.
You cannot apply a technological solution to a sociological problem. (Edwards' Law)
Actually, your OpenGL implementation is supposed to give you and error back. You have to call glGetError() to get it. In this case it should return GL_STACK_OVERFLOW.
I know first hand that this works under WindowsXP with the nVidia drivers. Not that the drivers should have anything to do with it.
As an aside, you should call glGetError() in a loop. There may be multiple errors waiting.
So either you had a broken OpenGL implementation or just forgot to call glGetError(). Anyway, just thought I'd point out that this isn't a generic OpenGL problem.
You are not a beautiful or unique snowflake -- but you could be if you got off your ass.
I've had that problem before, but it's not what you think (i think). Do you use zsh? Some shells, including zsh, protect their prompt. So if you print a single line w/o a \n, the prompt overwrites it, and you never see it. I think that bash by default will just print the prompt after whatever it was you printed. Try piping it to less or something, and you'll see it IS actually there :)
To smash a single atom, all mankind was intent / Now any day the atom may return the compliment
Oh, crud, it's still there.. Yeah. Sorry. I didn't notice, but here it is: the several active discussions page. These days it seems to mostly link to slashdot journals. Sorry, i somehow missed it when i was writing the parent post. I feel dumb.
/. crew doesn't mind me bringing attention to. I just think it's cool :)
I really, really hope this is something that the
Irritable, left-wing and possibly humorous bumper stickers and t-shirts
There is no "proper" way to reduce the precision of a number under all circumstances. Each method of rounding or truncating 0.5 has its own pitfalls:
So, as you can see, there's no right way per se. It just depends on what you're doing.
--JoeProgram Intellivision!
I thought it was pretty neat.
On the other hand, in c you could have just done the following:
#define colour color
another useful shortcut is to do this:
#define str chr* #define strs chr**
int main(int argc, strs argv, str env)
helps remove a few bugs from code you write.
Actually, the current HTML spec (4.01) states that </TH>, </TD>, and </TR> are all optional.
* Q
P.S. If you don't get this note, let me know and I'll write you another.
There are implementations in C, Java, PHP, Fortran, Excel (I assume VBA) and probably others.
I only have experience with the Java impl, and it is very good. There are two classes, MersenneTwister, which is a true descendant of java.util.Random, and there is also a MersenneTwisterFast class, which does NOT inherit from Random (same public methods, and identical algorithm though), but clocks in at about twice the speed, due to tricks like avoidance of synchronization, and method inlining and finalizing.
"Mind, as manifested by the capacity to make choices, is to some extent present in every electron." -Freeman Dyson
this is a guess...
the back-slash \ at the end of the line indicates to the compiler that the following line is to be considered part of the current line, meaning the compiler (iirc, lexical analyzer) will translate the above to the following:
#include
// tom 7 was here - 1998 \typedef unsigned char uchar;
int something(uchar c);
or more precisely--
--preprocessed contents of stdio.h--
int something(uchar c);
so the "bug" (actually a compile-time error) is an undefined token 'uchar,' unless of course, uchar has a definition in stdio.
The One Rule Of Chess You'll Ever Need: Don't play someone who carries a kit in their bookbag.
Was having some really bizzare problems with our String class being used in a stl vector and ended up having to trace it into the RougeWave HP stl. It was in vector<_TypeT,_Allocator>::operator= (const vector<_TypeT,_Allocator>& __x)
// size() < _x.size() < capacity()
// advance this->end () first
// size() < _x.size() < capacity()
// advance this->end () first
// write past original value of this->end ()
below is the change for anyone who might have hit this or runs this setup. Hope it can help someone avoid it and all the time it wasted. Just love problems in the STL! *** are the two lines changed.
*** _C_end_of_storage = _C_finish = _C_start + __x.size();
}
else {
*** _C_end_of_storage = _C_finish = _C_start + __x.size ();
Changed To:
*** _C_finish = _C_start + __x.size();
}
else {
copy (__x.begin (), __x.begin () + size (), begin ());
uninitialized_copy (__x.begin () + size (), __x.end (),
begin () + size (),
_RWSTD_VALUE_ALLOC_CAST (*this));
}
*** _C_end_of_storage = _C_finish = _C_start + __x.size ();
This of course was becuase _C_end_of_storage should not have been set before the calling of size() as it would be incorrect.
Just Another Day For You and Me in Paradise.