如何在PHP中获得浮点数的二进制表示? [英] How to get binary representation of floating-point number in PHP?
本文介绍了如何在PHP中获得浮点数的二进制表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
double x = Double.longBitsToDouble(Double.doubleToRawLongBits(d) - 1) ;
但是我在PHP中没有看到类似的东西。
pack()
Is there any way to get the binary representation of a floating point number in PHP? Something like Java's Double.doubleToRawLongBits().
Given a positive floating point number, I'd like to get the largest representable floating-point number which is less than that number. In Java, I can do it like this:
double x = Double.longBitsToDouble(Double.doubleToRawLongBits(d) - 1);
But I'm not seeing anything similar in PHP.
解决方案
This isn't a full answer, but the only way I know of to put a float into binary is with pack()
这篇关于如何在PHP中获得浮点数的二进制表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文