One of the most expensive lessons I learned building fintech products wasn't about APIs, infrastructure, or scaling.
It was about data types.
Years ago, while building a bill payment startup, I discovered we had silently lost over ₦3 million to fractional rounding issues.
No hacks.
No fraud.
Just floating-point arithmetic doing exactly what it was designed to do.
The Facts
In JavaScript, numbers are stored as floating-point values.
That means something as simple as:
0.1 + 0.2
doesn't equal 0.3.
It equals:
0.30000000000000004
For a shopping cart, that tiny difference may not matter.
For a fintech system processing thousands of transactions daily, those tiny fractions accumulate into real money.
What I Initially Did
Like many developers, I used decimal currency values directly:
const amount = 1250.75;
It looked clean.
But calculations, fee deductions, settlements, and balance updates gradually introduced rounding inconsistencies.
Over time, the system started leaking funds through fractions.
What Fixed It
I switched to storing monetary values in the currency's smallest unit using BigInt.
Instead of:
1250.75
Store:
125075n // Kobo
Now every operation becomes integer math.
No hidden fractions.
No rounding surprises.
No disappearing money.
Pros
- Precise calculations
- Predictable accounting
- Easier reconciliation
- Safer ledger systems
Cons
- Requires conversion when displaying values
- Slightly more discipline from developers
- BigInt cannot be mixed directly with Number types
Do's
> Store money in the smallest currency unit (Kobo, Cents, etc.)
> Use BigInt or dedicated decimal libraries where appropriate
> Convert only at the presentation layer
> Build your ledger around integer arithmetic
> Never convert BigInt to number on runtime to perform arithmetic operation. Perform the arithmetic operation on the BigInt Type. You can build an api transformer layer to return response in the integer form or leave value in the smallest unit while frontend do the conversion by dividing the value by 100.
Don'ts
X Store money as floating-point values
X Compare currency values using decimal calculations
X Round repeatedly during transaction processing
X Assume tiny fractions won't matter
Fun Fact
This is the same principle used by companies like Stripe. Amounts are represented in the smallest currency unit (such as cents) rather than floating-point dollars.
Wrap Up
In fintech, every fraction belongs to someone.
If your system cannot account for every smallest unit of currency, eventually those fractions become real losses.
The best time to fix monetary precision is before your first transaction. The second-best time is today.
One of the most expensive lessons I learned building fintech products wasn't about APIs, infrastructure, or scaling.
It was about data types.
Years ago, whil...