If you have been programming for a long time, chances are you will be aware of a well-known issue with the floating-point numbers. The "feature" or inaccuracy is that the floating-point numbers cannot be accurately represented by all base-10 decimals. This effects all programming languages and not isolated to Golang.

As you can see that the calculations are not reliable and inaccurate for the certain decimal values. The inaccuracy is caused by the underlying CPU and the native representation used by Golang (which is faster and optimized for performing a large number of calculations).

Depending on your application domain, most developers will use the standard float..... however, if you are programming applications for science and engineering domain that demand accuracy. Please do consider testing your application for the decimal "feature" or inaccuracy and use the appropriate package to address the inaccuracy.

By Adam Ng

IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.