ConFoo Montreal 2026: Call for Papers

Voting

: three plus one?
(Example: nine)

The Note You're Voting On

Ruben
12 years ago
While this function accepts floats for currency (in order to display cents), you should (for applications where this is critical) never store or handle money using floats, as rounding errors may occur. Work with integers (or a BigInt class if integers aren't large enough) internally instead, where the integer represents the total number of cents. An alternative (especially if you need more precision than cents) is using the BC (Binary Calculator) Math module, that handles arbitrary precision numbers with 100% accuracy.

<< Back to user notes page

To Top