• ray10k (unregistered)

So, on top of a rats nest of undocumented, convoluted code, they had a security problem as well?

• P (unregistered)

The best WTFs are the WTFs so bad users begin to work around it, creating a WTF wrapper.

• Little Bobby Tables (unregistered)

Perhaps there was a currency conversion going on? During the race to Euroify back in the late 90s or early 2000s or whenever it was, the rates were still being input in native currency (whatever that was) and converted to Euros on the fly using some vague guess at what the exchange rate might have been at one point, that is, 140 bodelscheisers to the Euro.

• (nodebb)

Sir your engine leaks oil and tires are bald. However that's not why your car doesn't start; the problem is you've been using the wrong key and fuel is empty.

• I dunno LOL ¯\(°_o)/¯ (unregistered)

This code has more casts than Evel Knievel after a crash.

• Jaloopa (unregistered)

I can almost see the fnords in that code

• Hans Solo (unregistered)

/140*100: 30 years ago Germany had a VAT of 14%.

• ooOOooGa (unregistered)

Let's see here...

Divide by 140, then multiply by 100. That is a really odd way of computing ~71%.

Cast that to fixed point to make sure it only has three decimal places. Then cast it to a string.

Recalculate that same 71% value and get the length of its string representation. Subtract one. Get the left-most substring of that length. Effectively, get all the characters, except that third decimal place.

Recalculate that 71% value a couple more times in order to get only the third decimal place. Change that value to be either '5' or '0'.

Assuming MSSQL so that the '+' is a string concatenation operator. Tack that truncated third decimal place back onto the end of the truncated 71% value. Then use that value to update the database table row.

Nope. No WTFs here. Calculating that particular value using only mathematical operators would be incredibly difficult. And of course you couldn't change the value calculated. Every half penny counts.

Granted there are some performance improvements that could be made. Notably, storing the 71% value instead of recalculating it four times. But let's not do any premature optimization. We can instead leave that as an employee performance validator - make sure that all employees who change code are completely paranoid about making sure that they change all instances of a complex calculation.

• I can be a robot if you want me to be (unregistered)

Ignoring the WTF of using SQL, in't the real issue that there's someone out there who doesn't check that code is called before investigating it?

• tbo (unregistered)

What the hell is that Discordia wiki actually about?

• Ann on a Mouse (unregistered) in reply to P

So… the POSIX shell, basically?

• Shill (unregistered)

This might be a case of someone using the actual meaning of the word cost. Note that what is passed in is the fee, i.e. what the customer pays. Recorded in the table is the cost, what the business paid for the merchandise. So the dividing by 140 etc is to undo the markup.

Or it could just be monkey code.

• ooOOooGa (unregistered) in reply to Shill

Huh?!? You are going to calculate the actual cost of shipping based on the shipping price charged to the customer?

I think that is a bit backwards.

• (nodebb) in reply to Little Bobby Tables

Oddity. In France, when you get a receipt in a shop / store / restaurant, it's fairly common to see the equivalent price in francs included, just in case 20 years later there's someone who really wants to know that.

• Zero (unregistered)

UpdateCartonCost plays no role in the outcome of the costs. If it weren't in the code, the developers would have still found the table, started updating it, misfire an update, and zeroed all, just like they did.

Discordianism is a religion. The Wiki is about it. https://en.wikipedia.org/wiki/Discordianism

• Ruts (unregistered)

just doing string munging to round off

I've been using the phrase 'munging' for years, so was quite surprised to see the really absurd and disturbing definition some wacko decided to put in for this word in Urban Dictionary. Look it up for yourself, so long as not easily offended or shocked!

• Luca (unregistered)

My favorite WTF since a long time. Caught me totally off guard!