1

I'm working with doubles and need to find the binary version of 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.

Any idea where I'm going wrong?

Community
  • 1
  • 1
notAChance
  • 1,360
  • 4
  • 15
  • 47

1 Answers1

3

this should work:

double myDouble = 827.0;
System.out.println(Long.toBinaryString((long) myDouble));
Ousmane D.
  • 54,915
  • 8
  • 91
  • 126