> ## Documentation Index
> Fetch the complete documentation index at: https://cantonfoundation-dpm-import.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# DA.Numeric

> Reference documentation for Daml module DA.Numeric.

<span id="module-da-numeric-17471" />

# DA.Numeric

## Module Snapshot

<CardGroup cols={2}>
  <Card title="Lifecycle">
    Stable.
  </Card>

  <Card title="Notices">
    Status: `active`
    Introduced in: `3.4.9`
    Removed in: `-`
    Warnings: `0`
    Deprecations: `0`
    Deprecated since: `-`
  </Card>
</CardGroup>

## Data Types

<span id="type-da-numeric-roundingmode-53864" />

### `data RoundingMode`

Rounding modes.

Constructors:

<span id="constr-da-numeric-roundingup-99831" />

* `RoundingUp`

Round away from zero.

<span id="constr-da-numeric-roundingdown-63242" />

* `RoundingDown`

Round towards zero.

<span id="constr-da-numeric-roundingceiling-67218" />

* `RoundingCeiling`

Round towards positive infinity.

<span id="constr-da-numeric-roundingfloor-71675" />

* `RoundingFloor`

Round towards negative infinity.

<span id="constr-da-numeric-roundinghalfup-22532" />

* `RoundingHalfUp`

Round towards the nearest neighbor unless both neighbors
are equidistant, in which case round away from zero.

<span id="constr-da-numeric-roundinghalfdown-91305" />

* `RoundingHalfDown`

Round towards the nearest neighbor unless both neighbors
are equidistant, in which case round towards zero.

<span id="constr-da-numeric-roundinghalfeven-70729" />

* `RoundingHalfEven`

Round towards the nearest neighbor unless both neighbors
are equidistant, in which case round towards the even neighbor.

<span id="constr-da-numeric-roundingunnecessary-42017" />

* `RoundingUnnecessary`

Do not round. Raises an error if the result cannot
be represented without rounding at the targeted scale.

## Functions

<span id="function-da-numeric-mul-81896" />

### `mul`

`mul` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n3` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n1` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n2` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n3`

Multiply two numerics. Both inputs and the output may have
different scales, unlike `(*)` which forces all numeric scales
to be the same. Raises an error on overflow, rounds to chosen
scale otherwise.

<span id="function-da-numeric-div-56407" />

### `div`

`div` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n3` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n1` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n2` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n3`

Divide two numerics. Both inputs and the output may have
different scales, unlike `(/)` which forces all numeric scales
to be the same. Raises an error on overflow, rounds to chosen
scale otherwise.

<span id="function-da-numeric-cast-54256" />

### `cast`

`cast` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n2` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n1` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n2`

Cast a Numeric. Raises an error on overflow or loss of precision.

<span id="function-da-numeric-castandround-59941" />

### `castAndRound`

`castAndRound` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n2` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n1` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n2`

Cast a Numeric. Raises an error on overflow, rounds to chosen
scale otherwise.

<span id="function-da-numeric-shift-13796" />

### `shift`

`shift` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n2` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n1` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n2`

Move the decimal point left or right by multiplying the numeric
value by 10^(n1 - n2). Does not overflow or underflow.

<span id="function-da-numeric-pi-88702" />

### `pi`

`pi` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n`

The number pi.

<span id="function-da-numeric-epsilon-3092" />

### `epsilon`

`epsilon` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n` => [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n`

The minimum strictly positive value that can be represented by a numeric of scale `n`.

<span id="function-da-numeric-roundnumeric-41344" />

### `roundNumeric`

`roundNumeric` : [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n` => [`Int`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`RoundingMode`](#type-da-numeric-roundingmode-53864) -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n` -> [`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n`

Round a `Numeric` number. The value of `round n r a` is the value
of `a` rounded to `n` decimal places (i.e. scale), according to the rounding
mode `r`.

This will fail when using the `RoundingUnnecessary` mode for a number that cannot
be represented exactly with at most `n` decimal places.

## Orphan Typeclass Instances

* instance [`NumericScale`](/appdev/reference/daml-standard-library/prelude#class-ghc-classes-numericscale-83720) `n` => [`Bounded`](/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) ([`Numeric`](/appdev/reference/daml-standard-library/prelude#type-ghc-types-numeric-891) `n`)
