Linked Questions

17 votes
3 answers
18k views

I am looking for the Python equivalent of Java's Float.floatToBits. I found this Python: obtain & manipulate (as integers) bit patterns of floats but does anyone know of a less complicated way?
learner's user avatar
  • 11.9k
13 votes
4 answers
12k views

In Python 2.5, I have a float and I'd like to obtain and manipulate its bit pattern as an integer. For example, suppose I have x = 173.3125 In IEEE 754 format, x's bit pattern in hexadecimal is ...
JaysonFix's user avatar
  • 2,605
1 vote
0 answers
1k views

When using this code import bitstring f = 1.0e+00 b = bitstring.pack('>d', f) b.bin I get 64 bits 001111111111000000000000000000000000000000000000000000000000000 But I need to get Float (IEEE754 ...
Salma El-Sokkary's user avatar
0 votes
0 answers
66 views

Is there any way to access the actual bits that are stored in memory for the floating-point variables in Python? I'm imagining something similar to bin() function (but with floats as inputs). I came ...
Vladimir Fokow's user avatar
1 vote
0 answers
57 views

Is there a way to print a floating point number in binary in Python? Something like >>> f"{0.5:b}" 0.1 ? The above doesn't work.
extremeaxe5's user avatar
158 votes
24 answers
551k views

I have ABC123EFFF. I want to have 001010101111000001001000111110111111111111 (i.e. binary repr. with, say, 42 digits and leading zeroes). How?
user avatar
0 votes
2 answers
14k views

Can anyone tell me how to convert a float number to 32-bit binary string and from a 32-bit binary string to a float number in python? 'bin' function in python works only for integers. I need a ...
user avatar
3 votes
1 answer
5k views

I would like to be able to extract the significand and exponent of floating-point numbers in NumPy. Getting the exponent as an integer is fine and ok for the significand. Getting the significand as a ...
equaeghe's user avatar
  • 1,814
14 votes
1 answer
5k views

The following code is part of a bigger project. In my project I have to read a large text file, with probably many million lines, with each line having a pair of decimals separated by space. An ...
Tom_K's user avatar
  • 141
1 vote
3 answers
2k views

Problem: Generate large binary strings (length 2000+). Do it quickly, as this generateRandom() function will be called 300,000 times in the algorithm. Attempted Solutions: Generate 3 or 4 binary ...
George Mausshardt's user avatar
2 votes
2 answers
2k views

I have a Tensorflow boolean vector that I need to bit-wise invert such that all the values that are 0 (False) becomes 1 (True) and vice-versa. tf.logical_not exists, but it only takes Boolean vectors. ...
pir's user avatar
  • 6,053
0 votes
3 answers
2k views

Python beginner here. I'm writing a program that uses an infinite loop and allows the user to enter key terms to access different 'tools' or 'modules'. Within one of these 'modules', the user can ...
Charlie Webb's user avatar
6 votes
2 answers
497 views

In octave, all the numerical output subsequent to the command format bit will show the native bit representation of numbers as stored in the memory. For example, octave:1> format bit octave:2> ...
A.Apte's user avatar
  • 105
-2 votes
1 answer
2k views

A converting between the decimal to single-precision floating,but i intro to this,so did any useful references or any summarize can help? Thousand Thanks! so,the python function will be like require ...
step's user avatar
  • 51
0 votes
1 answer
2k views

I have some software which takes as input the following format (which is doing it for MATLAB): [typecast(single(doubleNumber),'uint8') 0] where doubleNumber is an arbitrary floating number. How can I ...
strpeter's user avatar
  • 2,784

15 30 50 per page