|
26 | 26 | import static java.util.Arrays.asList;
|
27 | 27 |
|
28 | 28 | /**
|
29 |
| - * A representation of a 128-bit decimal. |
| 29 | + * A binary integer decimal representation of a 128-bit decimal value, supporting 34 decimal digits of significand and an exponent range |
| 30 | + * of -6143 to +6144. |
30 | 31 | *
|
31 | 32 | * @since 3.4
|
| 33 | + * @see <a href="https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst">BSON Decimal128 |
| 34 | + * specification</a> |
| 35 | + * @see <a href="https://en.wikipedia.org/wiki/Binary_Integer_Decimal">binary integer decimal</a> |
| 36 | + * @see <a href="https://en.wikipedia.org/wiki/Decimal128_floating-point_format">decimal128 floating-point format</a> |
| 37 | + * @see <a href="http://ieeexplore.ieee.org/document/4610935/">754-2008 - IEEE Standard for Floating-Point Arithmetic</a> |
32 | 38 | */
|
33 | 39 | public final class Decimal128 implements Serializable {
|
34 | 40 |
|
@@ -96,6 +102,10 @@ public final class Decimal128 implements Serializable {
|
96 | 102 | *
|
97 | 103 | * @param value the Decimal128 value represented as a String
|
98 | 104 | * @return the Decimal128 value representing the given String
|
| 105 | + * @throws NumberFormatException if the value is out of the Decimal128 range |
| 106 | + * @see |
| 107 | + * <a href="https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst#from-string-representation"> |
| 108 | + * From-String Specification</a> |
99 | 109 | */
|
100 | 110 | public static Decimal128 parse(final String value) {
|
101 | 111 | String lowerCasedValue = value.toLowerCase();
|
@@ -140,6 +150,7 @@ public Decimal128(final long value) {
|
140 | 150 | * Constructs a Decimal128 value representing the given BigDecimal.
|
141 | 151 | *
|
142 | 152 | * @param value the Decimal128 value represented as a BigDecimal
|
| 153 | + * @throws NumberFormatException if the value is out of the Decimal128 range |
143 | 154 | */
|
144 | 155 | public Decimal128(final BigDecimal value) {
|
145 | 156 | this(value, value.signum() == -1);
|
@@ -260,6 +271,8 @@ public long getLow() {
|
260 | 271 | * Gets a BigDecimal that is equivalent to this Decimal128.
|
261 | 272 | *
|
262 | 273 | * @return a BigDecimal that is equivalent to this Decimal128
|
| 274 | + * @throws ArithmeticException if the Decimal128 value is NaN, Infinity, -Infinity, or -0, none of which can be represented as a |
| 275 | + * BigDecimal |
263 | 276 | */
|
264 | 277 | public BigDecimal bigDecimalValue() {
|
265 | 278 |
|
@@ -364,7 +377,7 @@ public boolean isNaN() {
|
364 | 377 | /**
|
365 | 378 | * Returns true if the encoded representation of this instance is the same as the encoded representation of {@code o}.
|
366 | 379 | * <p>
|
367 |
| - * One consiquence is that, whereas {@code Double.NaN != Double.NaN}, |
| 380 | + * One consequence is that, whereas {@code Double.NaN != Double.NaN}, |
368 | 381 | * {@code new Decimal128("NaN").equals(new Decimal128("NaN")} returns true.
|
369 | 382 | * </p>
|
370 | 383 | * <p>
|
@@ -403,6 +416,13 @@ public int hashCode() {
|
403 | 416 | return result;
|
404 | 417 | }
|
405 | 418 |
|
| 419 | + /** |
| 420 | + * Returns the String representation of the Decimal128 value. |
| 421 | + * |
| 422 | + * @return the String representation |
| 423 | + * @see <a href="https://github.com/mongodb/specifications/blob/master/source/bson-decimal128/decimal128.rst#to-string-representation"> |
| 424 | + * To-String Sprecification</a> |
| 425 | + */ |
406 | 426 | @Override
|
407 | 427 | public String toString() {
|
408 | 428 | if (isNaN()) {
|
|
0 commit comments