MCPcopy Create free account
hub / github.com/questdb/questdb / Decimal

Interface Decimal

core/src/main/java/io/questdb/std/Decimal.java:45–176  ·  view source on GitHub ↗

Common interface for all decimal types (Decimal64, Decimal128, Decimal256). This interface defines the core operations required for decimal parsing and manipulation. All decimal types in QuestDB implement this interface to provide consistent behavior across different precision levels. T

Source from the content-addressed store, hash-verified

43 * @see DecimalParser
44 */
45public interface Decimal {
46 /**
47 * Adds a specific digit multiplied by a power of ten to the current decimal value.
48 * <p>
49 * This method is used during decimal parsing to build up the value digit by digit.
50 * It modifies the decimal in-place by adding (multiplier × 10^pow) to the current value.
51 * </p>
52 * <p>
53 * Example: To add the digit 5 at position 10^2 (hundreds place):
54 * <pre>
55 * decimal.addPowerOfTenMultiple(2, 5); // Adds 500 to the value
56 * </pre>
57 *
58 * @param pow the power of ten position (0 for ones, 1 for tens, 2 for hundreds, etc.)
59 * @param multiplier the digit to add (0-9); 0 is a no-op for efficiency
60 * @throws NumericException if the operation would cause overflow
61 */
62 void addPowerOfTenMultiple(int pow, int multiplier);
63
64 /**
65 * Returns the maximum precision (total number of significant digits) supported by this decimal type.
66 * <p>
67 * Precision limits vary by implementation:
68 * <ul>
69 * <li>Decimal64: 18 digits</li>
70 * <li>Decimal128: 38 digits</li>
71 * <li>Decimal256: 76 digits</li>
72 * </ul>
73 *
74 * @return the maximum number of significant digits this type can represent
75 */
76 int getMaxPrecision();
77
78 /**
79 * Returns the maximum scale (number of digits after the decimal point) supported by this decimal type.
80 * <p>
81 * Scale limits vary by implementation:
82 * <ul>
83 * <li>Decimal64: 18</li>
84 * <li>Decimal128: 38</li>
85 * <li>Decimal256: 76</li>
86 * </ul>
87 *
88 * @return the maximum number of decimal places this type can represent
89 */
90 int getMaxScale();
91
92 /**
93 * Returns true if this decimal represents the null value.
94 */
95 boolean isNull();
96
97 /**
98 * Negates this decimal value in-place, changing its sign.
99 * <p>
100 * If the decimal is positive, it becomes negative; if negative, it becomes positive.
101 * Zero remains zero. Null values remain null.
102 * <p>

Callers 1

Implementers 3

Decimal128core/src/main/java/io/questdb/std/Deci
Decimal256core/src/main/java/io/questdb/std/Deci
Decimal64core/src/main/java/io/questdb/std/Deci

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…