简体   繁体   English

Long.toBinaryString没有为827.0返回预期的二进制字符串

[英]Long.toBinaryString not returning expected binary string for 827.0

I'm working with double s and need to find the binary version of 827.0 . 我正在使用double s,需要找到827.0的二进制版本。

From looking around the way to do it is this . 从环顾四周来看是这样的

So I do: 所以我这样做:

double myDouble = 827.0;
Long.toBinaryString(Double.doubleToRawLongBits(myDouble))

However this is returning: 然而,这是回归:

100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000100000010001001110110000000000000000000000000000000000000000000

instead of 1100111011 . 而不是1100111011

Any idea where I'm going wrong? 知道我哪里错了吗?

this should work: 这应该工作:

double myDouble = 827.0;
System.out.println(Long.toBinaryString((long) myDouble));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM