Knowledgebase

Handling Money in Software Print

  • fintechpaymentsystems, fintech, woocommerce, nigeria, guide, howto, solution, zillionkinghost
  • 0

Practical correctness.

WHAT TO NEVER USE FOR MONEY

Floating point numbers.

WHY

They cannot represent common decimal values exactly, and errors accumulate.

WHAT TO USE INSTEAD

Integers in the smallest unit, or a decimal type.

WHAT THE SMALLEST UNIT IS

Kobo for naira, cents for dollars, and currencies with no subunit at all.

WHY THAT VARIATION MATTERS

Assuming two decimal places breaks for currencies that do not have them.

WHAT TO ALWAYS STORE WITH AN AMOUNT

Its currency.

WHY

An amount without a currency is meaningless and dangerous.

WHAT TO NEVER DO

Add amounts in different currencies Compare them without conversion

WHAT ROUNDING REQUIRES

A defined rule, applied consistently.

WHERE IT MATTERS MOST

Splitting amounts, where remainders must go somewhere.

WHAT TO DO WITH REMAINDERS

Allocate them deliberately, and record the rule.

WHAT TO BE CAREFUL WITH

Percentages applied to amounts Tax calculations, where the rule is prescribed Fees calculated on already-rounded values

WHAT TO TEST

Amounts producing awkward divisions Very large and very small amounts Every currency you handle


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot