Click here to Skip to main content
15,398,575 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB11-Jan-21 3:04
mveW Balboos, GHB11-Jan-21 3:04 
GeneralRe: The Decline and Fall of Search Engines Pin
Daniel Will9-Jan-21 4:30
MemberDaniel Will9-Jan-21 4:30 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB11-Jan-21 2:34
mveW Balboos, GHB11-Jan-21 2:34 
GeneralRe: The Decline and Fall of Search Engines Pin
Frank Malcolm8-Jan-21 10:40
MemberFrank Malcolm8-Jan-21 10:40 
GeneralRe: The Decline and Fall of Search Engines Pin
Member 133016798-Jan-21 11:16
MemberMember 133016798-Jan-21 11:16 
GeneralRe: The Decline and Fall of Search Engines Pin
Frank Malcolm8-Jan-21 15:17
MemberFrank Malcolm8-Jan-21 15:17 
GeneralRe: The Decline and Fall of Search Engines Pin
Member 133016799-Jan-21 0:04
MemberMember 133016799-Jan-21 0:04 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB10-Jan-21 2:43
mveW Balboos, GHB10-Jan-21 2:43 
The points are somewhat well known - but you then need to think of the situation in actual practice.

Work on a typical bill for online sales. "Pretend prices are stored as FP values"

Now generate an order. What you have is, almost invariably, a series of two-digit prices that are, indeed, subject to round-off errors. As you calculate the bill, you can add to or diminish item-counts and the price recalculated. When an amount reaches 0 (a uniquely annoying case as presented by the comment you responded to), it's 0 (an integer, by the way) * the price. This would be equal to true 0. For those that are not zeroed, there will, in general, be a round-off error in the representations. These will ultimately all be represented in the total. The total, however, is always rounded to a (for most currencies) a 2-decimal value (for Yen, as an example, they could possibly use integers?). So - if you consider the magnitude of the accumulated round-off errors, how will they effect the value in the second decimal place after rounding?

The reality, in a Real World Transaction, is that the given example using 0.1, 0.2, and 0.3 displays the error but does not display a retail reality: By how much do they actually differ in YOUR system? That is, (0.1 +0.2) - 0.3 = how much? Not zero? Correct! How close to even .01 does it get, that is, the smallest unit of currency?

Indeed, in the financial world, with money in the billions and even trillions of units, the errors can accumulate to real amounts (for each transaction, and this could be exploited). Possibly a uniquely bad problem in currency exchange markets.* But my point was about a business, even as large as Amazon, where transactions errors are trivial compared to the round-off point, and, at least where I live, they charge sales taxes - which themselves are number that essentially always result in fractional parts of currency and rounding. Frequently very close to that .005 of a unit.

With a transaction load as vibrant as amazons, the overhead in the precise representation vs. FP "native" types can add up. For a Point-of-Sale system I created quite some years ago, customers included Australian business: they currency is calculated in .01 $Aus units but the smallest coin was .05 $Aus. I needed to handle this, including possible refunds and unwinding/recalculating final bills after changes. Do you really think the difference is the 10th decimal place for a dry-cleaning bill will be significant by comparison? Especially, for the full-wide scope, with various regional taxes, environmental fees, &etc. multiplying these as well? Indeed, every step accumulate a tiny bit of error - and when the calculations were done and it went to the accountants, it was already "severely" modified to the nearest .01 (or, .05 ). That was what was paid/billed.

Solving a problem . . . requires a judicious balance between (alleged) best practices and the realities imposed by resources. If you're not working in an industry that requires specific data model by statute then you should read "Best Practices" as a recommendation and not the only way to do something. 'Best' is not at all the same as 'only'. That's where the thinking comes in.


* On such markets, even currencies that do not have decimal sub-units are, nonetheless, traded out to several decimal places. At this particular moment, the US$ is worth 103.9490 Japanese Yen. How much would a retail transaction in an online store have to buy for you to worry about the round-off errors if FP vs one of the other options? And what if stored as the integer (1039490), then final result divided by 10000 when done?
Ravings en masse^
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

GeneralRe: The Decline and Fall of Search Engines Pin
StarNamer@work21-Jan-21 4:36
professionalStarNamer@work21-Jan-21 4:36 
GeneralRe: The Decline and Fall of Search Engines Pin
Member 132567508-Jan-21 5:25
MemberMember 132567508-Jan-21 5:25 
GeneralRe: The Decline and Fall of Search Engines Pin
20212a7-Jan-21 1:46
Member20212a7-Jan-21 1:46 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB7-Jan-21 1:49
mveW Balboos, GHB7-Jan-21 1:49 
GeneralRe: The Decline and Fall of Search Engines Pin
Daniel Pfeffer7-Jan-21 3:41
professionalDaniel Pfeffer7-Jan-21 3:41 
GeneralRe: The Decline and Fall of Search Engines Pin
qmartens8-Jan-21 19:45
Memberqmartens8-Jan-21 19:45 
GeneralRe: The Decline and Fall of Search Engines Pin
qmartens8-Jan-21 19:45
Memberqmartens8-Jan-21 19:45 
GeneralRe: The Decline and Fall of Search Engines Pin
Paul Kemner7-Jan-21 4:35
MemberPaul Kemner7-Jan-21 4:35 
GeneralRe: The Decline and Fall of Search Engines Pin
dandy727-Jan-21 4:22
Memberdandy727-Jan-21 4:22 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB7-Jan-21 4:29
mveW Balboos, GHB7-Jan-21 4:29 
GeneralRe: The Decline and Fall of Search Engines Pin
dandy727-Jan-21 5:03
Memberdandy727-Jan-21 5:03 
GeneralRe: The Decline and Fall of Search Engines Pin
Mike Winiberg7-Jan-21 22:15
professionalMike Winiberg7-Jan-21 22:15 
GeneralRe: The Decline and Fall of Search Engines Pin
Carl_Sharman7-Jan-21 22:34
MemberCarl_Sharman7-Jan-21 22:34 
GeneralRe: The Decline and Fall of Search Engines Pin
W Balboos, GHB8-Jan-21 5:23
mveW Balboos, GHB8-Jan-21 5:23 
GeneralRe: The Decline and Fall of Search Engines Pin
Shmoken998-Jan-21 10:06
MemberShmoken998-Jan-21 10:06 
GeneralRe: The Decline and Fall of Search Engines Pin
OriginalGriff8-Jan-21 10:15
mveOriginalGriff8-Jan-21 10:15 
GeneralRe: The Decline and Fall of Search Engines Pin
Peter Shaw9-Jan-21 3:25
professionalPeter Shaw9-Jan-21 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Do you expect users to read the instructions when using your apps?
  Results   369 votes