not1but4 wrote: » At the risk of asking a very stupid question what is the issue with this? Is it the case if you where to use a 16 bit integer (range being -32768 to + 32767) You'd get the following; abs(-32767) = 32767 abs(-32768) = -32768 EDIT: What would be the correct implementation of this then?
Slutmonkey57b wrote: » But fundamentally one should be suspicious that a negative value is treated the same as its positive counterpart. They're different values for a valid reason so either you're missing an error or the calculation which returned somevar is set up incorrectly.
# figure out the absolute path to the script being run a bit # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the # specified directory, then uses $PWD to figure out where that # directory lives - and all this in a subshell, so we don't affect # $PWD STEAMROOT="$(cd "${0%/*}" && echo $PWD)" # Scary! rm -rf "$STEAMROOT/"*
Aswerty wrote: » But there is plenty of times where the reason for the differing signs doesn't matter with regards to what you are calculating. That's why the abs() function exists in the first place. So I don't think it is reasonable to consider ignoring the sign as fundamentally suspicious.
croo wrote: » I read this a while back and never noticed it mentioned .. anywhere never mind this thread. This code came from the installation script for Steam for Linux # figure out the absolute path to the script being run a bit # non-obvious, the ${0%/*} pulls the path out of $0, cd's into the # specified directory, then uses $PWD to figure out where that # directory lives - and all this in a subshell, so we don't affect # $PWD STEAMROOT="$(cd "${0%/*}" && echo $PWD)" # Scary! rm -rf "$STEAMROOT/"* Of course the flaw is obvious. Even to the developer given their "Scary!" comment... still it is very easy to install Linux isn't it? Full story was on the register a few months back.
Idleater wrote: » Related rhel bug ?https://bugzilla.redhat.com/show_bug.cgi?id=1202858 Had cause to Google Heisenbug this week, and duly found Hindenbug
Hindenbug
another_var -= abs(some_var);
line 896: protected void buttonGo_Click(object sender, EventArgs e) { // Loads of validation code line 994: if (myDropdown.SelectedValue = MyValues.Value1.ToString()) { // set a load of values in a repository // trigger a change in state } line 1291: else if (myDropdown.SelectedValue = MyValues.Value2.ToString()) { // set a load of the same values in a repository // trigger a different change in state } line 1306: else if (myDropdown.SelectedValue = MyValues.Value3.ToString()) { // set a load of the same values in a repository // trigger a different change in state } line 1321: else if (myDropdown.SelectedValue = MyValues.Value4.ToString()) { // set a load of the same values in a repository // trigger a different change in state } line 1456: else if (myDropdown.SelectedValue = MyValues.Value5.ToString()) { // set a load of the same values in a repository // trigger a different change in state } // six more of these else if statements line 2153: }
Eugene Norman wrote: » Switch statements are syntax sugar. It would still be as long a function, and long functions are my bugbear. Switch statements often -- like this else if -- have huge amounts of code per statement that could be factored out. also I don't know asp.net but surely a method could be set for each menu item.Edit. Oh, it looks like the same code bar some state setting is set in each if statement. I've seen the same in switch statements.
foreach (KeyValuePair<string, string> myData in SQLDal.GetSomeData()) { if (myData.Key.ToString() == keyDropDown.SelectedValue) { valueDropDown.SelectedValue = myData.Key; } else if (keyDropDown.SelectedValue.Trim() == "") { valueDropDown.SelectedValue = " "; } }
Tar.Aldarion wrote: » http://thedailywtf.com/articles/The-Speedup-Loop
SimonTemplar wrote: » Our core system is written in a proprietary language developed by our vendor and used only by the vendor’s applications. I occasionally do some coding in it mostly for data extracts. Was writing a script today and it was failing (it doesn’t provide a line number or even a reason for the error, just a big fat fail). Spent over an hour trying to debug and couldn’t understand what was happening. Got support from the vendor – it turns out that the language is designed so that you can only set the value of a variable once. If you try to change a variable’s value, it will fail. What a pile of absolute crap!!
Calina wrote: » Surely that's not then a variable, but a constant, no?
private void buttonHOSTESS_Click(object sender, EventArgs e) { if( buttonHOSTESS.Text == "OK") { this.Dispose(); } else {// Does the normal work here} }
BrokenArrows wrote: Decided to open up the code to have a quick look. Code: private void buttonHOSTESS_Click(object sender, EventArgs e) { if( buttonHOSTESS.Text == "OK") { this.Dispose(); } else {// Does the normal work here} } The customer had changed the login button from Ok to OK.
oscarBravo wrote: » The point that's being missed is that performing an action based on the text on a button - especially in a system that allows for localisation - is insanely, stupidly broken.
BrokenArrows wrote: » And also I have no idea why that was ever there. There is no reason to dispose the whole thing if the button was ok.