Consider below example
Convert 2.625 to binary.
We will consider the integer and fractional part separately.
The integral part is easy, 2 = 10.
For the fractional part:
0.625 × 2 = 1.25 1 Generate 1 and continue with the rest.
0.25 × 2 = 0.5 0 Generate 0 and continue.
0.5 × 2 = 1.0 1 Generate 1 and nothing remains.
So 0.625 = 0.101, and 2.625 = 10.101.
See this link for more information.
Related Contents:
- What is “2’s Complement”?
- Why prefer two’s complement over sign-and-magnitude for signed numbers?
- Tool for comparing 2 binary files in Windows [closed]
- Converting from an integer to its binary representation
- Binary representation of float in Python (bits not hex)
- What is “two’s complement”?
- Tools to help reverse engineer binary file formats
- How to detect type of compression used on the file? (if no file extension is specified)
- How do I create binary patches?
- Advantage of 2’s complement over 1’s complement?
- Really 1 KB (KiloByte) equals 1024 bytes?
- How do you convert a fraction to binary?
- Is it possible to program in binary?
- Convert hex to float
- What are important points when designing a (binary) file format? [closed]
- How many values can be represented with n bits?
- Is there a float input type in HTML5?
- How do I use a decimal step value for range()?
- How to format a float in javascript?
- How do you express binary literals in Python?
- Why are some float < integer comparisons four times slower than others?
- How to display a float with two decimal places?
- How do I check if a string represents a number (float or int)?
- What’s the difference between a single precision and double precision floating point operation?
- How do you embed binary data in XML?
- Division of integers in Java [duplicate]
- How can I convert integer into float in Java?
- 0.1 float is greater than 0.1 double. I expected it to be false [duplicate]
- How can I convert a string to a number in Perl?
- How can I improve performance via a high-level approach when implementing long equations in C++
- What is the difference between int() and floor() in Python 3?
- How many significant digits do floats and doubles have in java?
- How do I grep through binary files that look like text?
- How to check that a string is parseable to a double? [duplicate]
- Python float to int conversion
- Converting Float to Dollars and Cents
- Why does adding two decimals in Javascript produce a wrong result? [duplicate]
- double or float, which is faster? [duplicate]
- How to force GCC to assume that a floating-point expression is non-negative?
- How to compile a linux shell script to be a standalone executable *binary* (i.e. not just e.g. chmod 755)?
- In Java, how to get positions of ones in reversed binary form of an integer?
- Shortest way of checking if Double is “NaN”
- Embedding binary blobs using gcc mingw
- Compressing floating point data
- Scala Divide two integers and get a float result
- What is the best way to handle versioning using JSON protocol?
- Is floating point addition commutative in C++?
- Python OpenCV convert image to byte string?
- A realistic example where using BigDecimal for currency is strictly better than using double
- Clarification on the Decimal type in Python