## Description

BigToCompact converts a whole number N to a compact representation using an unsigned 32-bit number. The compact representation only provides 23 bits of precision, so values larger than (2^23 - 1) only encode the most significant digits of the number. See CompactToBig for details.

## Examples

} return BigToCompact(newTarget) }

// newTarget since conversion to the compact representation loses // precision. newTargetBits := BigToCompact(newTarget) log.Debugf("Difficulty retarget at block height %d", lastNode.height+1) log.Debugf("Old target %08x (%064x)", lastNode.bits, oldTarget)

for x, test := range tests { n := big.NewInt(test.in) r := blockchain.BigToCompact(n) if r != test.out { t.Errorf("TestBigToCompact test #%d failed: got %d want %d\n",

## BigToCompact is referenced in 2 repositories

**github.com/btcsuite/btcd**

- 2 references in blockchain/difficulty.go
- 1 reference in blockchain/difficulty_test.go
- 1 reference in blockchain/example_test.go

**github.com/OpenBazaar/spvwallet**

- 1 reference in blockchain.go