Decimal128 - a mutable decimal number implementation. The value is a signed number with two's complement representation. This class represents decimal numbers with a fixed scale (number of decimal places) using 128-bit integer arithmetic for precise calculations. All operations are performed in-
| 25 | * </p> |
| 26 | */ |
| 27 | public class Decimal128 implements Sinkable, Decimal { |
| 28 | public static final int BYTES = 16; |
| 29 | /** |
| 30 | * Maximum allowed precision (number of digits) |
| 31 | */ |
| 32 | public static final int MAX_PRECISION = 38; |
| 33 | /** |
| 34 | * Maximum allowed scale (number of decimal places) |
| 35 | */ |
| 36 | public static final int MAX_SCALE = 38; |
| 37 | public static final Decimal128 MAX_VALUE = new Decimal128(5421010862427522170L, 687399551400673279L); |
| 38 | public static final Decimal128 MIN_VALUE = new Decimal128(-5421010862427522171L, -687399551400673279L); |
| 39 | public static final Decimal128 NULL_VALUE = new Decimal128(Decimals.DECIMAL128_HI_NULL, Decimals.DECIMAL128_LO_NULL); |
| 40 | public static final Decimal128 ZERO = new Decimal128(0, 0, 0); |
| 41 | static final long LONG_MASK = 0xffffffffL; |
| 42 | /** |
| 43 | * Pre-computed powers of 10 table for decimal arithmetic. |
| 44 | * Autogenerated. See `Decimal128Test.testPowersTenTable`. |
| 45 | * |
| 46 | * <p> |
| 47 | * This table stores the 128-bit representation of powers of 10 (10^0 to 10^38) |
| 48 | * multiplied by digits 1-9. Each row contains 9 complete 128-bit values, where |
| 49 | * each 128-bit value is represented as 2 consecutive 64-bit longs: |
| 50 | * - High (bits 127-64) |
| 51 | * - Low (bits 63-0, least significant 64 bits) |
| 52 | * |
| 53 | * <p> |
| 54 | * Structure: table[power][multiplier_offset + component] |
| 55 | * - power: power of 10 (0 = 10^0, 1 = 10^1, ..., 38 = 10^38) |
| 56 | * - multiplier_offset: (multiplier-1) * 2, where multiplier ∈ [1,9] |
| 57 | * - component: 0=High, 1=Low |
| 58 | * |
| 59 | * <p> |
| 60 | * Example: To get 7 × 10^25: |
| 61 | * - Row: table[25] |
| 62 | * - Offset: (7-1) * 2 = 12 |
| 63 | * - Access: High=table[25][12], Low=table[25][13] |
| 64 | * - Value: (High << 64) | Low |
| 65 | */ |
| 66 | private static final long[][] POWERS_TEN_TABLE = new long[][]{ |
| 67 | {0L, 1L, 0L, 2L, 0L, 3L, 0L, 4L, 0L, 5L, 0L, 6L, 0L, 7L, 0L, 8L, 0L, 9L}, |
| 68 | {0L, 10L, 0L, 20L, 0L, 30L, 0L, 40L, 0L, 50L, 0L, 60L, 0L, 70L, 0L, 80L, 0L, 90L}, |
| 69 | {0L, 100L, 0L, 200L, 0L, 300L, 0L, 400L, 0L, 500L, 0L, 600L, 0L, 700L, 0L, 800L, 0L, 900L}, |
| 70 | {0L, 1000L, 0L, 2000L, 0L, 3000L, 0L, 4000L, 0L, 5000L, 0L, 6000L, 0L, 7000L, 0L, 8000L, 0L, 9000L}, |
| 71 | {0L, 10000L, 0L, 20000L, 0L, 30000L, 0L, 40000L, 0L, 50000L, 0L, 60000L, 0L, 70000L, 0L, 80000L, 0L, 90000L}, |
| 72 | {0L, 100000L, 0L, 200000L, 0L, 300000L, 0L, 400000L, 0L, 500000L, 0L, 600000L, 0L, 700000L, 0L, 800000L, 0L, 900000L}, |
| 73 | {0L, 1000000L, 0L, 2000000L, 0L, 3000000L, 0L, 4000000L, 0L, 5000000L, 0L, 6000000L, 0L, 7000000L, 0L, 8000000L, 0L, 9000000L}, |
| 74 | {0L, 10000000L, 0L, 20000000L, 0L, 30000000L, 0L, 40000000L, 0L, 50000000L, 0L, 60000000L, 0L, 70000000L, 0L, 80000000L, 0L, 90000000L}, |
| 75 | {0L, 100000000L, 0L, 200000000L, 0L, 300000000L, 0L, 400000000L, 0L, 500000000L, 0L, 600000000L, 0L, 700000000L, 0L, 800000000L, 0L, 900000000L}, |
| 76 | {0L, 1000000000L, 0L, 2000000000L, 0L, 3000000000L, 0L, 4000000000L, 0L, 5000000000L, 0L, 6000000000L, 0L, 7000000000L, 0L, 8000000000L, 0L, 9000000000L}, |
| 77 | {0L, 10000000000L, 0L, 20000000000L, 0L, 30000000000L, 0L, 40000000000L, 0L, 50000000000L, 0L, 60000000000L, 0L, 70000000000L, 0L, 80000000000L, 0L, 90000000000L}, |
| 78 | {0L, 100000000000L, 0L, 200000000000L, 0L, 300000000000L, 0L, 400000000000L, 0L, 500000000000L, 0L, 600000000000L, 0L, 700000000000L, 0L, 800000000000L, 0L, 900000000000L}, |
| 79 | {0L, 1000000000000L, 0L, 2000000000000L, 0L, 3000000000000L, 0L, 4000000000000L, 0L, 5000000000000L, 0L, 6000000000000L, 0L, 7000000000000L, 0L, 8000000000000L, 0L, 9000000000000L}, |
| 80 | {0L, 10000000000000L, 0L, 20000000000000L, 0L, 30000000000000L, 0L, 40000000000000L, 0L, 50000000000000L, 0L, 60000000000000L, 0L, 70000000000000L, 0L, 80000000000000L, 0L, 90000000000000L}, |
| 81 | {0L, 100000000000000L, 0L, 200000000000000L, 0L, 300000000000000L, 0L, 400000000000000L, 0L, 500000000000000L, 0L, 600000000000000L, 0L, 700000000000000L, 0L, 800000000000000L, 0L, 900000000000000L}, |
| 82 | {0L, 1000000000000000L, 0L, 2000000000000000L, 0L, 3000000000000000L, 0L, 4000000000000000L, 0L, 5000000000000000L, 0L, 6000000000000000L, 0L, 7000000000000000L, 0L, 8000000000000000L, 0L, 9000000000000000L}, |
| 83 | {0L, 10000000000000000L, 0L, 20000000000000000L, 0L, 30000000000000000L, 0L, 40000000000000000L, 0L, 50000000000000000L, 0L, 60000000000000000L, 0L, 70000000000000000L, 0L, 80000000000000000L, 0L, 90000000000000000L}, |
| 84 | {0L, 100000000000000000L, 0L, 200000000000000000L, 0L, 300000000000000000L, 0L, 400000000000000000L, 0L, 500000000000000000L, 0L, 600000000000000000L, 0L, 700000000000000000L, 0L, 800000000000000000L, 0L, 900000000000000000L}, |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…