Beispiel #1
0
func valueUnPack(fPrev float32, packed uint64) (length uint, value float32) {
	if one, _ := bitopts.TestBit64(packed, 63); !one {
		return 1, fPrev
	}

	leadzeroLen, _ := bitopts.GetField64(packed, 62, 58)
	sigbitLen, _ := bitopts.GetField64(packed, 57, 52)
	xorval, _ := bitopts.GetField64(packed, 51, uint(51-(sigbitLen-1)))

	trailzeroLen := 32 - (leadzeroLen + sigbitLen)
	xor32 := uint32(xorval << trailzeroLen)

	bval := (*(*uint32)(unsafe.Pointer(&fPrev))) ^ (*(*uint32)(unsafe.Pointer(&xor32)))

	value = (*(*float32)(unsafe.Pointer(&bval)))

	return uint(sigbitLen + 12), value
}
Beispiel #2
0
func timeUnPack(deltaSample, tPrev int64, packed uint64) (length uint, tVal int64) {
	if one, _ := bitopts.TestBit64(packed, 63); !one {
		return 1, tPrev + deltaSample
	}

	neg := false
	if one, _ := bitopts.TestBit64(packed, 62); one {
		neg = true
	}

	delta, _ := bitopts.GetField64(packed, 61, 57)

	deltaS := int64(delta)
	if neg {
		deltaS = -deltaS
	}

	return 7, tPrev + deltaSample + deltaS
}