com.r3corda.core.contracts / Amount

# Amount

`data class Amount : Comparable<Amount>`

Amount represents a positive quantity of currency, measured in pennies, which are the smallest representable units.

Note that "pennies" are not necessarily 1/100ths of a currency unit, but are the actual smallest amount used in whatever currency the amount represents.

Amounts of different currencies do not mix and attempting to add or subtract two amounts of different currencies will throw IllegalArgumentException. Amounts may not be negative. Amounts are represented internally using a signed 64 bit value, therefore, the maximum expressable amount is 2^63 - 1 == Long.MAX_VALUE. Addition, subtraction and multiplication are overflow checked and will throw ArithmeticException if the operation would have caused integer overflow.

TODO: It may make sense to replace this with convenience extensions over the JSR 354 MonetaryAmount interface TODO: Should amount be abstracted to cover things like quantities of a stock, bond, commercial paper etc? Probably. TODO: Think about how positive-only vs positive-or-negative amounts can be represented in the type system.

### Constructors

<init> | `Amount(amount: BigDecimal, currency: Currency)``Amount(pennies: Long, currency: Currency)` Amount represents a positive quantity of currency, measured in pennies, which are the smallest representable units.

### Properties

currency | `val currency: Currency`
pennies | `val pennies: Long`

### Functions

compareTo | `fun compareTo(other: Amount): Int`
div | `operator fun div(other: Long): Amount` `operator fun div(other: Int): Amount`
minus | `operator fun minus(other: Amount): Amount`
plus | `operator fun plus(other: Amount): Amount`
times | `operator fun times(other: Long): Amount` `operator fun times(other: Int): Amount`
toString | `fun toString(): String`

### Extension Properties

CASH | `val Amount.CASH: State`

### Extension Functions

times | `operator fun Amount.times(other: RatioUnit): Amount`