Source File
int128.go
Belonging Package
github.com/freeeve/gochickpeas
// acc128: a two-word two's-complement sum accumulator. Wide enough that an// int64-valued column summed over any node count the engine can hold never// overflows it, so the fits-int64 verdict at finalize depends on the true// total alone -- never on how work was partitioned across goroutines: a// transient excursion past int64 range that nets back in stays exact.package chickpeasimport// acc128 is the 128-bit signed accumulator; the zero value is 0.type acc128 struct {lo uint64hi uint64}// add folds one int64 in.func ( *acc128) ( int64) {var uint64.lo, = bits.Add64(.lo, uint64(), 0).hi += uint64(>>63) +}// merge folds another accumulator in (the parallel partial-merge step).func ( *acc128) ( acc128) {var uint64.lo, = bits.Add64(.lo, .lo, 0).hi += .hi +}// 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)}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |