Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
Another different approach maybe to have the money represented in the decimal in your database at the decimal places of the currency with the highest decimal point you are going to be dealing with for example using Decimal(n, 2) in case of fiat, and perform your calculations in arbitrary-precision Decimal type. In javascript, using libraries like Big.js , Decimal.js will be of help.
Another different approach maybe to have the money represented in the decimal in your database at the decimal places of the currency with the highest decimal point you are going to be dealing with for example using Decimal(n, 2) in case of fiat, and perform your calculations in arbitrary-precision Decimal type. In javascript, using libraries like Big.js , Decimal.js will be of help.
In Java and Ruby, BigDecimal is an inbuilt class that can be used. For PHP, you can checkout the Brick Math Library Basically, just find the arbitrary-precision Decimal type/Class/Library in your choice of language. Got another approach, please do let me know in comment section.
Related posts
- Decoding Why 0.6 + 0.3 = 0.8999999999999999 in JS and How to Solve?
- Solving the "floating point precision" problem with... floats?
- BigDecimal equivalent. What do you use?
- [AskJS] Are there numeric textbox widgets with built-in support for big numbers like decimal.js?
- Working with Currency Values in TypeScript