MCPcopy Create free account
hub / github.com/apple/foundationdb / _float_adjust

Function _float_adjust

bindings/python/fdb/tuple.py:67–73  ·  view source on GitHub ↗
(v, encode)

Source from the content-addressed store, hash-verified

65# If encoding and sign bit is 1 (negative), flip all of the bits. Otherwise, just flip sign.
66# If decoding and sign bit is 0 (negative), flip all of the bits. Otherwise, just flip sign.
67def _float_adjust(v, encode):
68 if encode and six.indexbytes(v, 0) & 0x80 != 0x00:
69 return b''.join(map(lambda x: six.int2byte(x ^ 0xff), six.iterbytes(v)))
70 elif not encode and six.indexbytes(v, 0) & 0x80 != 0x80:
71 return b''.join(map(lambda x: six.int2byte(x ^ 0xff), six.iterbytes(v)))
72 else:
73 return six.int2byte(six.indexbytes(v, 0) ^ 0x80) + v[1:]
74
75
76@functools.total_ordering

Callers 2

_decodeFunction · 0.85
_encodeFunction · 0.85

Calls 2

mapFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected