Need help?
<- Back

Comments (30)

  • sieve
    Accounting has the concept of materiality. But you still want the figures to tally to the last cent.One way to do this is to separate the computation/storage and presentation layer: use integers to store values as cents for computation/storage and only convert to dollars+cents on display. But then someone might suddenly demand three digits after the decimal point and you cannot go about changing every stored value just because the logic changed in one part of the application. So, using decimals is the safer choice.I prefer integers for my plain text ledger software though because the format is in my control.
  • kphorn
    Great blog post by Peter Gibbons, Michael Bolton, and Samir "Nagana-work-here-anymore" about their time at Initechhttps://www.youtube.com/watch?v=yZjCQ3T5yXo"all right so when the subroutine compounds the interest, it uses all of these extra decimal places that just get rounded off. So we simplified the whole thing, we round them all down and drop the remainder... in to an account that we opened"
  • amelius
    > Many people know that you shouldn’t do decimal calculations, such as those involving U.S. dollars and cents, with the floating-point numbers in most programming languages. This is because decimal numbers can’t be expressed exactly as such floating-point numbers, so you will encounter rounding errors.Why not, rounding to the nearest cent is going to be much less precise for any realistic amount of dollars when using 64 bit floats (the type of float Javascript uses in every browser).
  • sobriquet9
    Besides Python’s fractions, there are also constructive reals, exemplified by Android calculator where you can swipe any answer to get as many digits as you want.
  • krige
    Possibly the first case I've encountered where image loaded before the text. A grid of 1px rectangles? How unsettling.
  • jgalt212
    > Many people know that you shouldn’t do decimal calculations, such as those involving U.S. dollars and cents, with the floating-point numbers in most programming languages. This is because decimal numbers can’t be expressed exactly as such floating-point numbers, so you will encounter rounding errors.Decimals or pennies, you still have rounding errors. For example, if your contract is $100 / year. You will get the full $100 if you bill yearly, quarterly, or semi-annually. But if you bill monthly, no matter if you deal in pennies or fractional dollars, the sum total of your invoices for the year will be less than $100.
  • NaoEhSavio
    [flagged]