Example #1
0
File: gb.go Project: devick/flynn
func encFloatPrefix(prefix byte, f float64, b *[]byte) {
	u := math.Float64bits(f)
	var n uint64
	for i := 0; i < 8; i++ {
		n <<= 8
		n |= u & 0xFF
		u >>= 8
	}
	bits := mathutil.BitLenUint64(n)
	if bits == 0 {
		*b = append(*b, prefix)
		return
	}

	// 0 1 2 3 4 5 6 7 8 9
	// . 1 1 1 1 1 1 1 1 2
	encUintPrefix(prefix+1+byte((bits-1)>>3), n, b)
}
Example #2
0
File: gb.go Project: devick/flynn
func encUint(n uint64, b *[]byte) {
	bits := mathutil.Max(1, mathutil.BitLenUint64(n))
	encUintPrefix(gbUintP1+byte((bits-1)>>3), n, b)
}