Add Decimal64.scaleTo() 87/101287/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 May 2022 08:27:47 +0000 (10:27 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 25 May 2022 11:52:56 +0000 (13:52 +0200)
commitd7a4d9434e5e691f68d975955f78c887e0f1a9c1
treedfc6f2df3289912fb0acf9740dd1fddb38cea115
parent2fd1231f7d2d670420a872d219d9dd1d3158e526
Add Decimal64.scaleTo()

Decimal64.valueOf(String) results in variable-scale results, based on
the input string. This is sub-optimal when we want to compare values
of particular type -- those should be governed by fraction-digits and
hence, for example "2.00" and "2.0" should be normalized to the same
scale.

Introduce Decimal64.scaleTo(), which can be used to adjust the scale
of an existing Decimal64.

JIRA: YANGTOOLS-1440
Change-Id: Icbc215dff6d8146996c5be1040751fd1e14b6cfe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c6624c7716ea59e4df3cb7bf90d172e81a544be5)
common/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/Decimal64.java
common/yang-common/src/test/java/org/opendaylight/yangtools/yang/common/YT1440Test.java [new file with mode: 0644]