Skip to content

Instantly share code, notes, and snippets.

View maj-o's full-sized avatar

Andreas maj-o

  • Germany, Berlin
View GitHub Profile
maj-o /
Last active October 3, 2018 15:15
Golang 2 operator methods


We do a lot of calculations on currency values - calculating income taxes, bills, ... As You all know, float in any kind, does not work. (for those, who don't know that there is a problem: There are problems with float-types and there are problems without decimal type(s) - for instance this:!topic/golang-nuts/SfdApDgi4i8 ).

This is why there are so many implementations of a decimal type in different go packages. With all this packages and the build in types You can save Your decimal values to databases - one small step! But You can do nothing else. In Go there will be no serious calculations with decimals or any other not build in type. Because You have no operands for values of this types, You have to user Methods like Add, Mult and so on. This a No Go for uge calculations on (for instance) decimals.

What we do

We have realy a lot of currency calcualtions (each year new formulars for taxes and insurances) - there is no way using decimals for this, because i