>>> import struct
>>> struct.pack('f', 3.141592654)
b'\xdb\x0fI@'
>>> struct.unpack('f', b'\xdb\x0fI@')
(3.1415927410125732,)
>>> struct.pack('4f', 1.0, 2.0, 3.0, 4.0)
'\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@'
More Related Contents:
- Is floating point arbitrary precision available?
- How to suppress scientific notation when printing float values?
- Python JSON serialize a Decimal object
- How to display a float with two decimal places?
- Limiting floats to two decimal points
- How to get a random number between a float range?
- How to properly round-up half float numbers?
- How to get numbers after decimal point?
- round() doesn’t seem to be rounding properly
- Binary representation of float in Python (bits not hex)
- Convert floating point number to a certain precision, and then copy to string
- negative zero in python
- ValueError: could not convert string to float: id
- Easy pretty printing of floats?
- How do I use a decimal step value for range()?
- python floating number [duplicate]
- Add zeros to a float after the decimal point in Python
- Floating Point Limitations [duplicate]
- Rounding a number in Python but keeping ending zeros
- Strange behaviour with floats and string conversion
- Comparing floats in a pandas column
- numpy float: 10x slower than builtin in arithmetic operations?
- Why does the floating-point value of 4*0.1 look nice in Python 3 but 3*0.1 doesn’t?
- Python float to int conversion
- Most Pythonic way to print *at most* some number of decimal places [duplicate]
- Get the “bits” of a float in Python?
- Python, print all floats to 2 decimal places in output
- What are some possible calculations with numpy or scipy that can return a NaN? [closed]
- How do you get the next value in the floating-point sequence? [duplicate]
- on what systems does Python not use IEEE-754 double precision floats