INNER CODE UNIT · Go

cmpInt

ericlagergren/decimal · big.go:397

func cmpInt(x *Big, y int64) int {
	switch {
	case x.Signbit() && y >= 0:
		return -1
	case !x.Signbit() && y < 0:
		return +1
	default:
		return cmpAbsInt(x, y)
	}
}

func cmpAbsInt(x *Big, y int64) int {
	u := uint64(y)

	// Same scales, so compare straight across.
	if x.exp == 0 {
		// If the scales are the same and x x is not compact,
		// then by definition it's larger than y.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…