fromInteger

Returns a Decimal representing the specified value.

This function preserves the canonical representation of value.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

fun createsFromInteger(input: Integer, expected: String) {
val result: Decimal = Decimal.fromInteger(input)
check("$result" == expected)
}

createsFromInteger(input = Integer.fromLong(0), expected = "0")
createsFromInteger(input = Integer.fromLong(42), expected = "42")
createsFromInteger(input = Integer.fromLong(-42), expected = "-42")

Calling from Java

Here's an example of calling this function from Java code:

final BiConsumer<Integer, String> creates = (input, expected) -> {
final Decimal result = Decimal.fromInteger(input);
final boolean check = String.valueOf(result).equals(expected);
if (!check) throw new IllegalStateException("Check failed.");
};

creates.accept(Integer.fromLong(0), "0");
creates.accept(Integer.fromLong(42), "42");
creates.accept(Integer.fromLong(-42), "-42");