Skip to content
CCPEDIAby Unity Nodes
App Development

Numeric vs Decimal for currency

3 posts324 viewsLast activity Jan 2023

  1. Neelam_DwivediOP

    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?

  2. Gary_Verhaegen

    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.

  3. Neelam_Dwivedi

    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.