// acc128: a two-word two's-complement sum accumulator, mirroring the core
// package's unexported accumulator of the same shape (kept private in each
// package by design -- the engine's public surface carries a nullable
// int64, not a 128-bit type). Wide enough that an int64 column summed over
// any node count never overflows it, so the fits-int64 verdict depends on
// the true total alone; a transient excursion past int64 range that nets
// back in stays exact.

package exec

import 

// acc128 is the 128-bit signed accumulator; the zero value is 0.
type acc128 struct {
	lo uint64
	hi uint64
}

// add folds one int64 in.
func ( *acc128) ( int64) {
	var  uint64
	.lo,  = bits.Add64(.lo, uint64(), 0)
	.hi += uint64(>>63) + 
}

// int64 returns the total and whether it fits int64: the high word must be
// the sign extension of the low word's int64 reading.
func ( acc128) () (int64, bool) {
	 := int64(.lo)
	return , .hi == uint64(>>63)
}

// float64 is the total as a float, for the mixed int/float sum path. A
// total that fits int64 (the common case, including every small negative)
// converts exactly; the wide hi*2^64 + lo form is used only for a genuine
// out-of-int64 magnitude. Without the fits-int64 guard the wide form
// catastrophically cancels a small negative total: hi is the all-ones sign
// extension so hi*2^64 = -2^64, while lo (= 2^64 + total) rounds up to 2^64
// in float64, and the two annihilate -- e.g. a -5 total reads as 0.
func ( acc128) () float64 {
	if ,  := .int64();  {
		return float64()
	}
	return float64(int64(.hi))*0x1p64 + float64(.lo)
}