# Is there a way to do fixed-decimal math in Calc? [closed]

Have been fighting this for years. All spreadsheets (including LO Calc) use the standard IEEE or hardware float representation for numbers, then round off for display to the numeric format specified. Works well, but results in occasional "your answer is approximately nnnnn.nnnn" and comparison failure issues. IBM mainframes (and some old Borland languages) had packed-decimal or BCD math that was exact for specified decimal precision and rounding - what a bookkeeper wants. I recently found a *decimal* data type in Python that does something similar. Is there a way to use that concept in LO Calc without wrapping the whole Python decimal library into an extension of some kind, and figuring out how to call it? NOT a Python expert so this is more a theoretical question than one I can jump into right now.

Understood: this would not be portable outside of LO and possibly OO. Might still be useful.

Thanks.

Hi @mreky2, just curiosity, please can you share some of the situations bothering you?

It's not a real issue currently, but I've had problems in the past where comparing the results of 2 calculations involving multiplication/division looking for equal doesn't work because of differences out in the last few decimal places. There are workarounds, like ROUND or INT before comparison, but inconvenient to remember when working quickly. Also, in some financial work, the results should be exact, not just display rounding. Obviously not big or would have been fixed long ago.

This is called for example a Java BigDecimal ( https://docs.oracle.com/javase/7/docs... ) - values which are not represented in a binary system with a floating point but in a decimal system with a set precision and defined rounding behaviour. The fact that Spreadsheets in 2019 do not explicitly support such a type can only be called "problematic" at best. If a professional accounting package used floats to represent monetary amounts the company responsible would hopefully be sued silly. See also: https://stackoverflow.com/questions/3...