We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a490307 commit 4b269f0Copy full SHA for 4b269f0
python-ecosys/cbor2/cbor2/_encoder.py
@@ -59,7 +59,15 @@ def encode_float(encoder, value):
59
elif math.isinf(value):
60
encoder.write(b"\xf9\x7c\x00" if value > 0 else b"\xf9\xfc\x00")
61
else:
62
- encoder.write(struct.pack(">Bd", 0xFB, value))
+ std = struct.pack(">f", value)
63
+ if struct.unpack(">f", std)[0] != value:
64
+ encoder.write(struct.pack(">Bd", 0xFB, value))
65
+ else:
66
+ half = struct.pack(">e", value)
67
+ if struct.unpack(">e", half)[0] != value:
68
+ encoder.write("\xfa" + std)
69
70
+ encoder.write("\xf9" + half)
71
72
73
def encode_int(encoder, value):
python-ecosys/cbor2/manifest.py
@@ -1,3 +1,3 @@
1
-metadata(version="1.0.0", pypi="cbor2")
+metadata(version="1.1.0", pypi="cbor2")
2
3
package("cbor2")
0 commit comments