Floats for Currency

The cluster debates the dangers of using floating-point numbers for monetary values and calculations due to precision and rounding errors, advocating for decimal types, fixed-point integers, or arbitrary-precision alternatives in finance and accounting software.

📉 Falling 0.3x Finance & Crypto
4,902
Comments
19
Years Active
5
Top Authors
#3976
Topic ID

Activity Over Time

2008
13
2009
39
2010
78
2011
77
2012
110
2013
127
2014
211
2015
272
2016
153
2017
294
2018
365
2019
431
2020
469
2021
427
2022
368
2023
694
2024
475
2025
294
2026
5

Keywords

e.g OR PHP TL wolframalpha.com IBM EDIT apple.com LibreOffice JavaScript decimal floating point floating precision floats integers calculations errors rounding currency

Sample Comments

nly • Jan 28, 2014 • View on HN

Anyone who doesn't need more than 6 digits of decimal precision but can't be arsed to scale everything in to a fixed point format.

jbl • Nov 15, 2010 • View on HN

What is the issue with using floating point to represent money?

mietek • Dec 20, 2014 • View on HN

Have programmers stopped representing monetary values using floating point yet?

jey • Oct 9, 2013 • View on HN

Why does scientific computing care about decimal arithmetic?

shakna • Jan 6, 2019 • View on HN

IBM Decimals are the standard for finance applications. Integers, not floating point.Floats don't have the precision required.

hnews_account_1 • Oct 24, 2022 • View on HN

You’re misunderstanding the problem. It isn’t storage, it is calculation. You cannot do away with decimals because calculations are not always linear. There are several logarithms, exponents and root finding algorithms used in finance which you’d have to write several additional rules for if you can’t represent decimals. It’s not like mathematicians thought decimals were just a convenience so you don’t have to show large integers. They’re fundamentally not integers.

chongli • Jun 29, 2021 • View on HN

Using float for currency calculations is how you accumulate a bunch of rounding errors. Standard practice when dealing with money is to use an arbitrary-precision numerical type.

Gibbon1 • Jan 5, 2019 • View on HN

You don't need an exact number but customer data is universally decimal. Soon as you blindly convert that to IEE754 everything is now broken.

throwaway613834 • Nov 30, 2017 • View on HN

How do finance folks deal with decimals? Doesn't Excel use binary floats? Do they switch to integers?

kephra • Apr 14, 2015 • View on HN

e.g. money is badly represented as float.just my $0.0200000000001 on that topic.