The idempotency keys section alone is worth the read most devs learn that lesson the hard way.
__natty__ · 2026-06-27 11:28:53 UTC
Also audit trails. Good audit trail can save company (and you) in emergency as well. Useful for debugging and last resort of compliance data source.
mrkeen · 2026-06-27 17:09:42 UTC
I just build the audit trails and skip the non audit trails.
That way I can debug and have a last resort of compliance, but also save time by not building the first resort of compliance.
pards · 2026-06-27 11:32:40 UTC
100%. It deserves more detail, too.
I've spent many hours explaining how idempotency is supposed to work, and why it's important. Most teams understand the need for it, but very few thought about it up front.
lxgr · 2026-06-27 12:24:42 UTC
I just wish the financial industry itself had known about these when the core banking systems and financial communication protocols of the 60s and 70s were invented that are still being used to this day...
Many of these predate the widespread knowledge of idempotency, so often idempotency keys are hacked together by joining various, hopefully globally unique fields, except that they never quite are. (You can look behind the curtain sometimes, e.g. when your bank does not let you transfer the same amount to the same recipient account on the same calendar day.)
dc_giant · 2026-06-27 11:02:30 UTC
Sorry have to ask these days. Is this carefully written down information from years of experience in the field or AI slop?
thewisenerd · 2026-06-27 11:07:01 UTC
from the author's mastodon post [0]
I just published Fintech Engineering Handbook distilled from 6 years of tears, sweat and swears.
It’s a free ~25-page resource with various hints and patterns around handling money.
Tell me what you think!
other than that, peruse the commits on the source [1], or wait for the author to respond.
Appears that the author got some help organizing the document, but wrote it all themselves.
zipy124 · 2026-06-27 11:15:40 UTC
Whilst I wouldn't say anything in it requires years of experience to know, this would be helpful for someone who hasn't considered anything about monetary systems. It doesn't read like slop, but I could be wrong but even so it all seems fairly reasonable (I've only fully read about 50% before realising there's nothing new here for me, and then skimmed to rest).
manwithopinions · 2026-06-27 11:20:59 UTC
Skimmed it and based on my experience in fintech, it looks good, accurately represents the real world. I guess there’s still a chance it is AI generated but it doesn’t seem like vacuous slop, it has substance!
krever · 2026-06-27 12:02:34 UTC
Hey, author here :)
Its at least 80% organic artisanal writing and maybe 20% AI when I needed help with grammar, completeness, broader perspective and everything around.
logdahl · 2026-06-27 12:39:28 UTC
It may be a good idea to start the book with a really short "About the author" to state exactly this and your work experience. Otherwise looks well written to me, good job! :)
gib444 · 2026-06-27 16:37:59 UTC
Native English speaker. I scanned it and IMO there's a slight overuse/misuse of hyphens. Maybe the AI tool could be asked to identify and correct? (The hyphens might be triggering people to think it's AI, too).
They mostly need replacing with a full stop or a colon.
E.g.
"In practice this means storing the amount as an integer in its smallest unit - €12.34 becomes 1234"
->
"In practice, this means storing the amount as an integer in its smallest unit: €12.34 becomes 1234."
or
"In practice, this means storing the amount as an integer in its smallest unit (e.g., €12.34 becomes 1234)"
m00x · 2026-06-27 20:12:50 UTC
Hyphens here are meant to be formatting. You would be correct if this was a literary piece, but handbooks and sheets don't need to use these rules.
jyounker · 2026-06-27 20:50:04 UTC
It's a misuse because in this context the hyphen could be mis-construed as a negative amount, and this causes the reader to stop and carefully re-read the content to ensure that they're not misinterpreting it. That's not where you want to be spending your reader's attention.
gib444 · 2026-06-28 06:39:33 UTC
Spelling, grammar and punctuation matter everywhere, in my opinion.
I wouldn't have read your comment if it were all lowercase and used zero punctuation, for example.
jyounker · 2026-06-27 20:51:12 UTC
I worked for a few years in consumer banking, and this looks like solid advice.
lxgr · 2026-06-27 11:22:35 UTC
Word of advice to anyone considering the "minor-units precision" strategy for representing monetary amounts: Don't (or at least, don't use it as an interchange/API data format).
It seems like a clever idea (fast integer math, no rounding problems for addition and subtraction), but it'll bite you incredibly hard if you ever stumble upon an edge case such as working with a partner that has a different implied number of digits for a given currency. This is especially relevant for stablecoins, which often have a different number of implied decimal digits than the "fiat" currency they represent.
Also, consider representing amounts as a string type in JSON-based APIs. JSON does not specify decimal precision, so you (and all your users/vendors) will always have to make sure your parser/serializer doesn't internally lose precision by going via floating point. This can get ugly fast, and while a string seems conceptually less neat, it completely bypasses that problem. (Some will call this an anti-pattern [1], but I'd rather not fight this particular battle for ideological purity on the shoulders of my users or shareholders.)
What do you recommend instead? Standard floating-point ("float"/"double"), fixed-point arithmetic with thousandths (or smaller) of the minor unit, arbitrary-precision decimal numbers, or something else entirely?
lxgr · 2026-06-27 11:39:07 UTC
I think what matters most is your database and API representation, as well as having consistent and well-defined rounding rules.
I largely agree with TFA: Round explicitly and consistently whenever you cross a boundary, i.e. database persistence and internal API calls.
Use whatever works for your required business case internally (i.e. inside of procedures calculating some function of one or more input amounts). This can be regular old floats/doubles if you absolutely know what you're doing, or BigDecimal if you aren't and would rather suffer slightly slower performance than having to talk to an auditor about IEEE 754 rounding modes, or even minor-amount integers (yes, even though I just said to not use them – but you'll want to ABSOLUTELY NEVER leak them outside of your system, including your data/analytics pipeline, which might have different ideas about financial amounts than your business logic implementing a nice custom monetary type).
ivanmontillam · 2026-06-27 11:40:28 UTC
A string type. As parent says: it completely bypasses the problem. Save the numbers between double quotes and be done with it.
portly · 2026-06-27 12:26:15 UTC
Storing numbers as arrays of u8? That doesn't make sense
ivanmontillam · 2026-06-27 13:01:20 UTC
For JSON serialization, which doesn't support fixed-point precision it does.
Floating-point precision has too many gotchas for being suitable to store Decimal types, especially for the Currency use case.
How is that better than {“amount”: “10.00”} (which also bypasses all potential floating point parsing issues that your or your counterparty’s JSON library might have)?
jameshart · 2026-06-27 14:15:03 UTC
It is explicit about the fact that that number of decimal places is part of the data.
The semantics for your string “10.00” are complex - is it considered equal to “10”? To “10.000”? To “10.001”?
A user interacting with an API that uses such a string might make all sorts of assumptions about what it supports.
A user interacting with an API that has an explicit decimal places concept is being told ‘decimals matter! They can vary! Here be dragons!’
lxgr · 2026-06-27 15:07:06 UTC
> The semantics for your string “10.00” are complex - is it considered equal to “10”?
Yes, but "10 USD" would be a non-canonical representation and you probably serialized incorrectly.
> To “10.000”?
Yes, but same caveat as above applies.
> To “10.001”?
Obviously not, and any system you'd ever want to use in a financial context will tell you so.
notpushkin · 2026-06-29 05:19:57 UTC
String and two-field exponent/mantissa representations are mostly the same in terms of semantics, yes. Making it two separate fields makes it less likely it would be put into `parseFloat`, but after doing some research I think strings are more popular in JSON [1, 2], so probably I’d stick to that as well.
It makes a lot of sense if you value correctness over performance.
microgpt · 2026-06-27 13:46:48 UTC
Why not store them in unary then?
lxgr · 2026-06-27 14:28:43 UTC
Unary is exactly as expressive as decimal or binary for integers, but somewhat less efficient, so why would you?
microgpt · 2026-06-27 15:29:53 UTC
idk, why would you store integers as ASCII strings? It's somewhat less efficient.
lxgr · 2026-06-27 16:05:40 UTC
Because it's much more explicit. Computers are fast, engineering is expensive. You usually never want to optimize prematurely when dealing with monetary amounts.
microgpt · 2026-06-28 09:21:10 UTC
Even more explicit would be a PNG of the dollar bills. I suggest that.
lxgr · 2026-06-27 14:34:42 UTC
Except that now you have a new problem: Opinionated theorists that haven’t been part of a nasty “oh no, we accidentally considered some amounts as 10x/100x/1000x larger/smaller than expected” incident in their career yet…
KellyCriterion · 2026-06-27 11:54:28 UTC
Do not throw away any precision in finance/money computation, regardless what/ how you are doing it.
In C# e.g., there is type decimal for those computations.
lxgr · 2026-06-27 12:02:29 UTC
You'll definitely have to throw it away at some point.
The art is in making those points well-defined and rare enough to not cause large discrepancies, but frequent enough to avoid ballooning arbitrary-precision numbers across databases and services that might not be able to handle them.
krever · 2026-06-27 13:07:48 UTC
I really like that phrasing!
Would you mind if I steal in some form if I decide to review this part of the book?
lxgr · 2026-06-27 13:41:55 UTC
Not at all, and thanks for writing all of this up!
necrotic_comp · 2026-06-27 12:33:17 UTC
Floating point value stored multiplied by 10^8. That gives you a huge integer, but it's extremely accurate, especially for US denominated currencies. Easily transformed into floating point numbers for reporting/etc.
denismenace · 2026-06-27 11:28:09 UTC
> but it'll bite you incredibly hard if you ever stumble upon an edge case such as working with a partner that has a different implied number of digits for a given currency
Why would that be a problem? You just transform the values when interacting with their API.
lxgr · 2026-06-27 11:29:23 UTC
Sure, but are all your (and your users' and vendors') engineers and LLM agents going to remember that? When in doubt, always be explicit.
makeitdouble · 2026-06-27 11:56:31 UTC
I'm curious how you handle that.
Let's say I operate with a 4 decimal expectation and your API expects 6, is there any way to reconcile that outside of documentation and or metadata ? (which would be the same issue I guess whatever representation is used ?)
lxgr · 2026-06-27 12:00:24 UTC
Yeah, you need to document it.
Still, even if you do: Chances that your users are just going to assume you're conforming to ISO 4217, some national standard, or your competitor that they're already integrated with are pretty high, so I wouldn't take the chance. Pick something that doesn't have to be documented instead.
xlii · 2026-06-27 12:07:03 UTC
Exactly, model is in integers and representation can be 1⃣3⃣ or whatever, that's why model-view separation exist.
lxgr · 2026-06-27 12:21:07 UTC
Sure, you can do that if you can absolutely guarantee that everyone will always respect that separation and there will never be ambiguity between your internal and some partner's representation – even during incidents, even during low-level CSV-to-DB ETLs during incidents ("just one time, I promise, we don't have time to build the proper adapter, but look how similar their and our formats are").
microgpt · 2026-06-27 13:33:15 UTC
Customer was charged $0.995 after fees, how to represent in your data model with integer cents?
xprnio · 2026-06-27 14:20:50 UTC
Round it up
microgpt · 2026-06-27 15:30:12 UTC
Charge $0.995
Refund $1.00
Repeat
SJC_Hacker · 2026-06-28 06:02:47 UTC
Charge $0.995
Charge Actual $1.00
Refund $1.000
Alternately
Charge $0.995
ERROR CHARGE AMOUNT MUST BE ROUNDED TO NEAREST CENT
microgpt · 2026-06-28 09:22:05 UTC
In my scenario your payment gateway added a $0.005 fee. You told it $0.99.
lxgr · 2026-06-27 15:10:21 UTC
You'll have to decide when and how to round. Keeping individual billing items at high precision and rounding after summing them up can work; defining and documenting a rounding policy (or complying with whatever's legally required in your jurisdiction/domain) and rounding each individual billed item can as well.
snsnsjjsjsiisa · 2026-06-27 16:38:02 UTC
You use 1/1000th or 1/10000th or whatever you need. You do not need “cents”.
denismenace · 2026-06-27 18:23:58 UTC
Currency: USD
Amount: 99500
Decimals: 5
microgpt · 2026-06-28 09:21:29 UTC
Congrats m8 you invented floating point
denismenace · 2026-06-28 15:38:27 UTC
Then you have no idea how floating point works. (Hint: its in the name)
FabHK · 2026-06-28 15:29:12 UTC
How is the client going to pay that? They can't be charged half a cent.
afavour · 2026-06-27 14:26:10 UTC
Because a lot of the time there won’t be any error when you’re wrong, just silent data loss.
andylynch · 2026-06-27 15:14:43 UTC
I’ve seen bugs like this in prod systems. The notional value of the error tends to make the people concerned anything but silent.
antonymoose · 2026-06-27 12:33:10 UTC
Having done HFT / low-latency in C++ with a browser based (read: JavaScript) management front-end: Go ahead and use integer cents everyone. It’s practically an industry standard and it works just fine. Anything else is a worse compromise.
DetroitThrow · 2026-06-27 13:18:37 UTC
Agree with this, working from HFT to payments to account management in the past.
You can have the blockchain team be an expert in converting integer cents, or the forex team be an expert in sub-cent conversions. You don't want to require _every team_ to have expertise in float math, by default.
lxgr · 2026-06-27 14:43:43 UTC
Big decimals are widely available and don’t require any expertise but avoid many of the footguns of implied decimal integers.
Maxatar · 2026-06-27 20:05:09 UTC
Imagine advising someone who explicitly said they work in HFT to use big decimals.
m00x · 2026-06-27 20:06:39 UTC
BigDecimal should be used by almost everyone except for HFT since they're really slow.
DetroitThrow · 2026-06-28 19:07:07 UTC
When performance isn't a concern, I largely agree! Not every financial system can use big decimal as their base, though, too. And HFT isn't the only place in the financial sector where this performance concern might pop up.
notpushkin · 2026-06-27 13:18:54 UTC
It is fine as long as you don’t cross any edge cases (crypto, or more recently stuff like AI token pricing) and don’t forget to account for third party quirks (e.g. Stripe’s zero-decimal currencies: https://docs.stripe.com/currencies#zero-decimal).
lxgr · 2026-06-27 14:27:40 UTC
JPY not having any minor units is arguably not a “third party quirk” but just how the currency works. The same goes for various three decimal digit currencies.
notpushkin · 2026-06-28 20:36:42 UTC
I mean yeah, but it does make things more complicated. Currencies change to 0-decimal, but some systems still expect 2-decimal representation for backcompat reasons (like ISK and UGX in Stripe).
notpushkin · 2026-06-29 05:08:10 UTC
(To clarify some more, we’re in agreement here. My point was mainly that “just storing cents” seems like an easy solution and it might seem to be working well – until it’s not :-)
lxgr · 2026-06-27 14:25:07 UTC
If you’re only trading in USD and other two-decimal currencies it can work fine, yes. For anything else, it’s much worse as also detailed in TFA.
antonymoose · 2026-06-27 19:22:48 UTC
You provide different handling strategies for different currencies. You also sort currency data alongside your amount. There is nothing complicated or edge-case here.
This works for USD, JPY or $MEMECOIN and it scales very well.
amluto · 2026-06-27 16:49:43 UTC
If someone sells you 12345.55 EUR vs USD at a rate of 1.12345, how many EUR do you think you end up with? Do you think all market participants even agree? What if the rate is 1.123456?
For added fun, you can introduce division. Some systems will allow you to sell 12345.55 USD to buy EUR at a rate of 1.12345.
The article’s “no lost data” tenet is not really viable when this sort of division is involved. Are you going to track your account balance is a rational number with an absolutely immense denominator forever?
antonymoose · 2026-06-27 19:18:58 UTC
You store the sums on either end, the currencies, the exchange rate and the final sum? No one has .0000145 cents in their account. Rounding occurs in the real world.
amluto · 2026-06-27 20:01:33 UTC
> You store the sums on either end, the currencies, the exchange rate and the final sum?
There is a remarkable amount of disagreement as to whether one should do one’s back office work based on the price or based on the quantity of the counter currency.
> No one has .0000145 cents in their account. Rounding occurs in the real world.
Indeed. But you either need to convince all parties to agree to round the same way or you need to accept small errors
jyounker · 2026-06-27 20:46:50 UTC
My experience in consumer banking says that every instrument specifies the precision of the calculation, how and when rounding happens, and slew of
little details.
So, yes, everyone has to understand how all their partners are doing rounding and summing.
amluto · 2026-06-27 23:04:43 UTC
In certain areas of the institutional finance world, everyone seems to accept that everyone's math is allowed to differ by a few cents, and they tally up the errors and move on with their lives.
I would, however, by quite surprised if my personal bank account did this.
SJC_Hacker · 2026-06-28 06:15:39 UTC
When the bank owes you money, they round down.
When you owe the bank money, they round up.
walthamstow · 2026-06-28 07:11:02 UTC
Unless you work for the bank, in which case your annual salary is divided by 12 and rounded up for a monthly figure.
dumah · 2026-06-27 20:10:21 UTC
Of course market participants agree?
Exchanges have calculation rules for every type of mark and payment and will always specify rounding.
SJC_Hacker · 2026-06-28 06:14:13 UTC
The only one who has to “agree” is the exchange. And it should be covered by the TOS
FabHK · 2026-06-28 15:27:06 UTC
> If someone sells you 12345.55 EUR vs USD at a rate of 1.12345, how many EUR do you think you end up with?
1. If someone sells me 12345.55 EUR, I hope to end up with 12345.55 EUR.
2. That's the point though. They will sell you a certain amount of EUR at a certain dollar price. This, in turn, implies a rate (which might well have more than 5 digits behind the decimal). This is ideally close to the quoted rate, sure. But what counts is the actual EUR amount and the actual USD amount, not what rate was quoted or with how many digits.
noitpmeder · 2026-06-27 12:57:32 UTC
The only real correct solution here is to send mantissa and exponent as two separate integers. It's trivial to convert between exponents for whatever math you want, it can be as correct as you want, and is unambiguous.
In the HFT space you save some wire space if you can commit to a consistent exponent for some {slice} up front (think instrument/tick-size/asset-class/exchange/feed/server/whatever/...) such that you only need to send the mantissa and your clients can have a hard coded exponent. However, in similar spaces it's often worth the extra uint32 to send a on-the-wire exponent such that things _can_ change and you aren't hamstrung later by earlier "we only need cents now!" design choices when, e.g., you suddenly need to support bitcoin/... prices to full precision. (your users will thank you when they don't have to coordinate a breaking change when you want to adjust your fixed exponent)
microgpt · 2026-06-27 13:32:08 UTC
If you do that though aren't you just reinventing floating-point?
jjmarr · 2026-06-27 16:18:40 UTC
No, because you're doing decimal floating point, which eliminates the rounding errors of binary floating point.
No, standard floating point implementations have higher precision for smaller numbers than larger. So for example, in a 32bit float, there are far more numbers between 0-1 than there are between 1,000,000 and 1,000,001. For 32bit floats, you start lowing whole integers with relatively small numbers.
Integers have a consistent precision across the entire number line.
lxgr · 2026-06-27 13:35:20 UTC
> The only real correct solution here is to send mantissa and exponent as two separate integers.
That’s essentially the same thing as a String-serialized big decimal, just less readable, no?
gmm1990 · 2026-06-27 15:13:10 UTC
That’s quite a bit slower to process. At least if you’re converting to integers to do the calculations and the calculations would be quite a bit slower if you kept the big decimal type
lxgr · 2026-06-27 15:18:58 UTC
True, but this is usually your least concern when you're dealing with monetary amounts/math.
mnahkies · 2026-06-27 16:08:43 UTC
They specifically mentioned HFT so I suspect they care a lot about processing speed
Comments
That way I can debug and have a last resort of compliance, but also save time by not building the first resort of compliance.
I've spent many hours explaining how idempotency is supposed to work, and why it's important. Most teams understand the need for it, but very few thought about it up front.
Many of these predate the widespread knowledge of idempotency, so often idempotency keys are hacked together by joining various, hopefully globally unique fields, except that they never quite are. (You can look behind the curtain sometimes, e.g. when your bank does not let you transfer the same amount to the same recipient account on the same calendar day.)
[0]: https://mas.to/@krever/116814803588993437
[1]: https://github.com/Krever/fintech-engineering-handbook/commi...
Its at least 80% organic artisanal writing and maybe 20% AI when I needed help with grammar, completeness, broader perspective and everything around.
They mostly need replacing with a full stop or a colon.
E.g.
"In practice this means storing the amount as an integer in its smallest unit - €12.34 becomes 1234"
->
"In practice, this means storing the amount as an integer in its smallest unit: €12.34 becomes 1234."
or
"In practice, this means storing the amount as an integer in its smallest unit (e.g., €12.34 becomes 1234)"
I wouldn't have read your comment if it were all lowercase and used zero punctuation, for example.
It seems like a clever idea (fast integer math, no rounding problems for addition and subtraction), but it'll bite you incredibly hard if you ever stumble upon an edge case such as working with a partner that has a different implied number of digits for a given currency. This is especially relevant for stablecoins, which often have a different number of implied decimal digits than the "fiat" currency they represent.
Also, consider representing amounts as a string type in JSON-based APIs. JSON does not specify decimal precision, so you (and all your users/vendors) will always have to make sure your parser/serializer doesn't internally lose precision by going via floating point. This can get ugly fast, and while a string seems conceptually less neat, it completely bypasses that problem. (Some will call this an anti-pattern [1], but I'd rather not fight this particular battle for ideological purity on the shoulders of my users or shareholders.)
[1] https://blog.json-everything.net/posts/numbers-are-numbers-n...
I largely agree with TFA: Round explicitly and consistently whenever you cross a boundary, i.e. database persistence and internal API calls.
Use whatever works for your required business case internally (i.e. inside of procedures calculating some function of one or more input amounts). This can be regular old floats/doubles if you absolutely know what you're doing, or BigDecimal if you aren't and would rather suffer slightly slower performance than having to talk to an auditor about IEEE 754 rounding modes, or even minor-amount integers (yes, even though I just said to not use them – but you'll want to ABSOLUTELY NEVER leak them outside of your system, including your data/analytics pipeline, which might have different ideas about financial amounts than your business logic implementing a nice custom monetary type).
Floating-point precision has too many gotchas for being suitable to store Decimal types, especially for the Currency use case.
The semantics for your string “10.00” are complex - is it considered equal to “10”? To “10.000”? To “10.001”?
A user interacting with an API that uses such a string might make all sorts of assumptions about what it supports.
A user interacting with an API that has an explicit decimal places concept is being told ‘decimals matter! They can vary! Here be dragons!’
Yes, but "10 USD" would be a non-canonical representation and you probably serialized incorrectly.
> To “10.000”?
Yes, but same caveat as above applies.
> To “10.001”?
Obviously not, and any system you'd ever want to use in a financial context will tell you so.
[1]: https://msgspec.dev/supported-types#decimal
[2]: e.g. https://getlago.com/docs/api-reference/fees/fee-object#schem..., although they still use `amount_cents` for all currencies as the base rate
In C# e.g., there is type decimal for those computations.
The art is in making those points well-defined and rare enough to not cause large discrepancies, but frequent enough to avoid ballooning arbitrary-precision numbers across databases and services that might not be able to handle them.
Why would that be a problem? You just transform the values when interacting with their API.
Let's say I operate with a 4 decimal expectation and your API expects 6, is there any way to reconcile that outside of documentation and or metadata ? (which would be the same issue I guess whatever representation is used ?)
Still, even if you do: Chances that your users are just going to assume you're conforming to ISO 4217, some national standard, or your competitor that they're already integrated with are pretty high, so I wouldn't take the chance. Pick something that doesn't have to be documented instead.
Refund $1.00
Repeat
Charge Actual $1.00
Refund $1.000
Alternately
Charge $0.995
ERROR CHARGE AMOUNT MUST BE ROUNDED TO NEAREST CENT
You can have the blockchain team be an expert in converting integer cents, or the forex team be an expert in sub-cent conversions. You don't want to require _every team_ to have expertise in float math, by default.
This works for USD, JPY or $MEMECOIN and it scales very well.
For added fun, you can introduce division. Some systems will allow you to sell 12345.55 USD to buy EUR at a rate of 1.12345.
The article’s “no lost data” tenet is not really viable when this sort of division is involved. Are you going to track your account balance is a rational number with an absolutely immense denominator forever?
There is a remarkable amount of disagreement as to whether one should do one’s back office work based on the price or based on the quantity of the counter currency.
> No one has .0000145 cents in their account. Rounding occurs in the real world.
Indeed. But you either need to convince all parties to agree to round the same way or you need to accept small errors
So, yes, everyone has to understand how all their partners are doing rounding and summing.
I would, however, by quite surprised if my personal bank account did this.
When you owe the bank money, they round up.
Exchanges have calculation rules for every type of mark and payment and will always specify rounding.
1. If someone sells me 12345.55 EUR, I hope to end up with 12345.55 EUR.
2. That's the point though. They will sell you a certain amount of EUR at a certain dollar price. This, in turn, implies a rate (which might well have more than 5 digits behind the decimal). This is ideally close to the quoted rate, sure. But what counts is the actual EUR amount and the actual USD amount, not what rate was quoted or with how many digits.
In the HFT space you save some wire space if you can commit to a consistent exponent for some {slice} up front (think instrument/tick-size/asset-class/exchange/feed/server/whatever/...) such that you only need to send the mantissa and your clients can have a hard coded exponent. However, in similar spaces it's often worth the extra uint32 to send a on-the-wire exponent such that things _can_ change and you aren't hamstrung later by earlier "we only need cents now!" design choices when, e.g., you suddenly need to support bitcoin/... prices to full precision. (your users will thank you when they don't have to coordinate a breaking change when you want to adjust your fixed exponent)
https://en.wikipedia.org/wiki/Decimal128_floating-point_form...
What noitpmeder described is just floating point.
Integers have a consistent precision across the entire number line.
That’s essentially the same thing as a String-serialized big decimal, just less readable, no?