Updated on 2026-08-14
This commit is contained in:
parent
e79d1c1290
commit
5d8461a4f2
8 changed files with 19 additions and 47 deletions
|
|
@ -2,11 +2,14 @@ package com.tangem.utils.extensions
|
|||
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
* Converts `BigDecimal?` to `BigDecimal`
|
||||
*
|
||||
* If `BigDecimal?` is `null`, returns `BigDecimal.ZERO`
|
||||
*/
|
||||
/** Returns [BigDecimal] or [BigDecimal.ZERO] if [this] is null */
|
||||
fun BigDecimal?.orZero(): BigDecimal = this ?: BigDecimal.ZERO
|
||||
|
||||
fun BigDecimal.isZero(): Boolean = this.compareTo(BigDecimal.ZERO) == 0
|
||||
/** Checks if [this] is [BigDecimal] */
|
||||
fun BigDecimal.isZero(): Boolean = this.compareTo(BigDecimal.ZERO) == 0
|
||||
|
||||
/** Checks if [this] is positive */
|
||||
fun BigDecimal.isPositive(): Boolean = this.signum() == 1
|
||||
|
||||
/** Removes trailing zeros and returns plain [String] */
|
||||
fun BigDecimal.stripZeroPlainString(): String = this.stripTrailingZeros().toPlainString()
|
||||
Loading…
Add table
Add a link
Reference in a new issue