我可以使用精度为(float32)的python float吗?

时间:2017-04-11 01:34:51

标签: serialization tensorflow floating-point precision msgpack

我可以使用精度为(float32)的python float吗? 因为它将从原始python.float(32)序列化,并将被反序列化为原始java.float。 不考虑任何库。 ex)numpy.float32

1 个答案:

答案 0 :(得分:0)

Python浮点数是64位(C / Java中的double)。但是,您可以使用float格式"f"模块将这些序列化/反序列化为32位浮点数(C / Java中的>>> import struct >>> struct.pack("f", 0.1) '\xcd\xcc\xcc=' ):

string[] nullCollection = null;
IEnumerable<string> ienumerable = new[] { nullCollection }.SelectMany(a => a);

bool isnull = ienumerable.GetEnumerator().Current == null;
if (!isnull)
{
    bool isany = ienumerable.Any();
}