Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Numeric vs Decimal for currencyForum ↗

Numeric vs Decimal for currency

App Development3 posts279 viewsLast activity Jan 2023
NE
Neelam_DwivediOP
Jan 2023

For a variable that holds currency, such as $, that has only two digits after decimal-point representing cents, isn’t it better to define it as Numeric 2 instead of Decimal? Or is there any underlying difference that one should be aware of?

GA
Gary_Verhaegen
Jan 2023

Decimal is an alias for Numeric 10, so in principle there is no underlying difference except for the number of decimal places.

Whether 2 or 10 decimal places is best for your use-case will of course depend on said use-case.

NE
Neelam_Dwivedi
Jan 2023

Thanks @Gary_Verhaegen!

I think the advantage I see when using Numeric 2 is that prints are cleaner with only two digits after decimal-point instead of so many trailing zeroes.

Most of the code examples for Daml-learners have used Decimal for currency so I wondered.

← Back to Discussions