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

Method hasCarry

core/src/main/java/io/questdb/std/Decimal256.java:668–672  ·  view source on GitHub ↗

Check if addition resulted in a carry When adding two unsigned numbers a + b = sum, carry occurs iff sum < a (or sum < b) This works because: - No carry: sum = a + b, so sum >= a and sum >= b - Carry: sum = a + b - 2^64, so sum < a and sum < b

(long a, long sum)

Source from the content-addressed store, hash-verified

666 * - Carry: sum = a + b - 2^64, so sum < a and sum < b
667 */
668 public static boolean hasCarry(long a, long sum) {
669 // We can check against either a or b - both work
670 // Using a for consistency, b parameter kept for clarity
671 return (sum + Long.MIN_VALUE) < (a + Long.MIN_VALUE);
672 }
673
674 /**
675 * Returns whether the Decimal256 is null or not.

Callers 4

toSinkMethod · 0.95
uncheckedAddMethod · 0.95
addMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected