c# - BitConverter.DoubleToInt64Bits equivalent in python -


I really understand the best way to feel about double exact numbers, play a bit with them, and One of the things I want to do is to see their (almost) binary representation, in C #, the function BitConverter.DoubleToInt64Bits is very useful because (after converting to hexadecimal ) I want to say "real" of the temporary point number Puts a look at Riti.

The problem is that I do not seem to be able to find equivalent function in Python, is there a way to do the same things in a BitConverter.DoubleToInt64Bits a python function?

Thank you.


Edit:

The was used in the suggested answer. In the form of hexlif (struct.pack ('d', 123.456) inascii.hexlify (struct.pack (', D', 123.456))

Returns ' 77be 9f1a2fdd5e40' , but if I run the code that should be equal in C #, i.e.

  BitConverter.DoubleToInt64Bits (123.456) .ostring (" X ")   

I get a completely different number: " 405EDD2F1A 9FBE77 " .w I have made my mistake here?

How about using more?

  & gt; & gt; import Basics>> gt; & gt; In Structure.pack ('d', 0.0) 'Structure.pack' in Structure.p;> \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 '> > Binascii '0000000000000000' & gt; Binascii.hexlify (struct.pack ('d', 1.0)) '000000000000f03f' & gt; & gt;   d <<> code < Code> c type (8 bytes = 64 bits) for other formats,  @ ,  = ,  by specifying  

UPDATE

> & Lt; , & gt; , ! As the first letter in the format, you can point to the byte sequence ()

  & gt; & Gt; & Gt; Binascii.hexlify (struct.pack ('& lt; d', 123.456)) # Small-Endian '77be 9f1a2fdd5e40' & gt; & Gt; & Gt; Binascii.hexlify (struct.pack ('> D', 123.456) # Big-endian '405edd2f1a9fbe77'    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -