15,396,859 members

# The Weird and The Wonderful

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 Re: To get a %age divide the number by the number of decimal places defined on the column CHill6013-Dec-19 1:42 CHill60 13-Dec-19 1:42
 Re: To get a %age divide the number by the number of decimal places defined on the column Marc Clifton13-Dec-19 2:39 Marc Clifton 13-Dec-19 2:39
 Re: To get a %age divide the number by the number of decimal places defined on the column Nelek13-Dec-19 3:04 Nelek 13-Dec-19 3:04
 Re: To get a %age divide the number by the number of decimal places defined on the column Marc Clifton13-Dec-19 4:05 Marc Clifton 13-Dec-19 4:05
 Re: To get a %age divide the number by the number of decimal places defined on the column Nelek13-Dec-19 4:11 Nelek 13-Dec-19 4:11
 Re: To get a %age divide the number by the number of decimal places defined on the column CHill6013-Dec-19 5:07 CHill60 13-Dec-19 5:07
 Re: To get a %age divide the number by the number of decimal places defined on the column Nelek13-Dec-19 3:08 Nelek 13-Dec-19 3:08
 Re: To get a %age divide the number by the number of decimal places defined on the column Tiger1250619-Dec-19 15:33 Tiger12506 19-Dec-19 15:33
 This is a really old programming problem. How would you store a running total of a bank account? Since it has dollars and cents, how about a float? Ok, so then you run into the "floating-point rounding error" problem. Copy Code ```>>> 0.1+0.1+0.1 0.30000000000000004``` Well... that's pretty bad to be adding/dropping pennies every trillion transactions or so because of cumulative binary representation of decimal digit errors. What else can we do? One of the commonly chosen ways is to used fixed decimal. i.e. Assume a fixed number of decimals and represent everything as integers. One no longer has to worry about fractions of a penny creeping up on you over time if you work in discrete units of pennies. i.e. 100-97 = 3, never 0.30000000000000004 Well... then your manager comes in and says, we need to be able to track hundredths of a penny because the state tax paid even including fractions of a penny. So it is deemed that 4-digits is enough precision to satisfy the need. Now 10000 - 9700 = 300 is still okay, is never gonna be 300.00000000000004 and the same situation applies as before. But your front-end buddies didn't update the website to account for the fact that the database now assumes 4 digits of precision. And thus the problem is born. Fun trivia: "Office Space" movie characters took advantage of this to siphon off millions of dollars back when this was a thing in the 80s-90s-00s.
 Re: To get a %age divide the number by the number of decimal places defined on the column CHill6019-Dec-19 21:08 CHill60 19-Dec-19 21:08
 Re: Dev time waster ala JSON dialect Jon McKee9-Dec-19 13:13 Jon McKee 9-Dec-19 13:13
 Re: Dev time waster ala JSON dialect raddevus10-Dec-19 3:32 raddevus 10-Dec-19 3:32
 Re: Dev time waster ala JSON dialect kmoorevs10-Dec-19 6:36 kmoorevs 10-Dec-19 6:36
 Re: Dev time waster ala JSON dialect raddevus11-Dec-19 2:40 raddevus 11-Dec-19 2:40
 Re: Dev time waster ala JSON dialect Sander Rossel11-Dec-19 2:10 Sander Rossel 11-Dec-19 2:10
 Re: Dev time waster ala JSON dialect raddevus11-Dec-19 2:46 raddevus 11-Dec-19 2:46
 Re: Dev time waster ala JSON dialect Sander Rossel11-Dec-19 3:42 Sander Rossel 11-Dec-19 3:42
 Re: Dev time waster ala JSON dialect raddevus11-Dec-19 4:32 raddevus 11-Dec-19 4:32
 Re: Dev time waster ala JSON dialect Sander Rossel11-Dec-19 4:37 Sander Rossel 11-Dec-19 4:37
 Re: Dev time waster ala JSON dialect F-ES Sitecore11-Dec-19 3:47 F-ES Sitecore 11-Dec-19 3:47
 Re: Dev time waster ala JSON dialect   Forogar  11-Dec-19 4:27 Forogar 11-Dec-19 4:27
 Re: Dev time waster ala JSON dialect Sander Rossel11-Dec-19 4:39 Sander Rossel 11-Dec-19 4:39
 Re: Dev time waster ala JSON dialect raddevus11-Dec-19 4:34 raddevus 11-Dec-19 4:34
 Re: Dev time waster ala JSON dialect Bernhard Hiller5-Jan-20 21:49 Bernhard Hiller 5-Jan-20 21:49
 Re: Dev time waster ala JSON dialect englebart11-Dec-19 2:50 englebart 11-Dec-19 2:50
 Last Visit: 31-Dec-99 18:00     Last Update: 16-Aug-22 6:39 Refresh ᐊ Prev1...33343536373839404142 Next ᐅ