answersLogoWhite

0


Best Answer

In C++ you can get the address of a float, which is of type float*. Use reinterpret_cast to cast the address to an int* (ints are 4 bytes large, just like floats). After this create a temporary integer, and initialize it to the target of that int*. Use right bitshifts and bitwise AND operations to isolate each individual bit (starting with the highest order bit or lowest order bit, depending on if the system you're compiling for is big-endian or little-endian, respectively). Output this one digit after another and you will have the bit representation for the floating point number.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert a floating point number into a binary form?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Math & Arithmetic

How do you represent floating point number in microprocessor?

It is somewhat complicated (search for the IEEE floating-point representation for more details), but the basic idea is that you have a few bits for the base, and a few bits for the exponent. The numbers are stored in binary, not in decimal, so the base and the exponent are the numbers "a" and "b" in a x 2b.


How can you convert 110.101into decimalnumber system?

110.101 is already a decimal number. Unless that is intended to be two binary numbers with a decimal point between them for some reason. (decimal points are not used to represent fractional numbers in the binary system).


What is remainder in numbers?

A remainder is the numbers after a decimal point; sometimes used as repesenting in binary to get a binary number from a decimal number.


How are floating point numbers handled as binary numbers?

Floating point numbers are typically stored as numbers in scientific notation, but in base 2. A certain number of bits represent the mantissa, other bits represent the exponent. - This is a highly simplified explanation; there are several complications in the IEEE floating point format (or other similar formats).Floating point numbers are typically stored as numbers in scientific notation, but in base 2. A certain number of bits represent the mantissa, other bits represent the exponent. - This is a highly simplified explanation; there are several complications in the IEEE floating point format (or other similar formats).Floating point numbers are typically stored as numbers in scientific notation, but in base 2. A certain number of bits represent the mantissa, other bits represent the exponent. - This is a highly simplified explanation; there are several complications in the IEEE floating point format (or other similar formats).Floating point numbers are typically stored as numbers in scientific notation, but in base 2. A certain number of bits represent the mantissa, other bits represent the exponent. - This is a highly simplified explanation; there are several complications in the IEEE floating point format (or other similar formats).


How is scientific notation related to the floating point representation used by computers?

Floating point numbers are stored in scientific notation using base 2 not base 10.There are a limited number of bits so they are stored to a certain number of significant binary figures.There are various number of bytes (bits) used to store the numbers - the bits being split between the mantissa (the number) and the exponent (the power of 10 (being in the base of the storage - in binary, 10 equals 2 in decimal) by which the mantissa is multiplied to get the binary/decimal point back to where it should be), examples:Single precision (IEEE) uses 4 bytes: 8 bits for the exponent (encoding ±), 1 bit for the sign of the number and 23 bits for the number itself;Double precision (IEEE) uses 8 bytes: 11 bits for the exponent, 1 bit for the sign, 52 bits for the number;The Commodore PET used 5 bytes: 8 bits for the exponent, 1 bit for the sign and 31 bits for the number;The Sinclair QL used 6 bytes: 12 bits for the exponent (stored in 2 bytes, 16 bits, 4 bits of which were unused), 1 bit for the sign and 31 bits for the number.The numbers are stored normalised:In decimal numbers the digit before the decimal point is non-zero, ie one of {1, 2, ..., 9}.In binary numbers, the only non-zero digit is 1, so *every* floating point number in binary (except 0) has a 1 before the binary point; thus the initial 1 (before the binary point) is not stored (it is implicit).The exponent is stored by adding an offset of 2^(bits of exponent - 1), eg with 8 bit exponents it is stored by adding 2^7 = 1000 0000Zero is stored by having an exponent of zero (and mantissa of zero).Example 10 (decimal):10 (decimal) = 1010 in binary → 1.010 × 10^11 (all digits binary) which is stored in single precision as:sign = 0exponent = 1000 0000 + 0000 0011 = 1000 00011mantissa = 010 0000 0000 0000 0000 0000 (the 1 before the binary point is explicit).Example -0.75 (decimal):-0.75 decimal = -0.11 in binary (0.75 = ½ + ¼) → 1.1 × 10^-1 (all digits binary) → single precision:sign = 1exponent = 1000 0000 + (-0000 0001) = 0111 1111mantissa = 100 0000 0000 0000 0000 0000Note 0.1 in decimal is a recurring binary fraction 0.1 (decimal) = 0.0001100110011... in binary which is one reason floating point numbers have rounding issues when dealing with decimal fractions.

Related questions

C program to receive floating point and convert it into binary?

scanf


The IEE standared 32 bit floating point representation of the binary number 19.5 is?

0 10000011 11100000000000000000000


Clearly explain the functions that the mantissa and exponent have in floating point number?

Think of the floating-point number as a number in scientific notation, for example, 5.3 x 106 (i.e., 5.3 millions). In this example, 5.3 is the mantissa, whereas 6 is the exponent. The situation is slightly more complicated, in that floating-point numbers used in computers are stored internally in binary. Some precision can be lost when converting between decimal and binary.Think of the floating-point number as a number in scientific notation, for example, 5.3 x 106 (i.e., 5.3 millions). In this example, 5.3 is the mantissa, whereas 6 is the exponent. The situation is slightly more complicated, in that floating-point numbers used in computers are stored internally in binary. Some precision can be lost when converting between decimal and binary.Think of the floating-point number as a number in scientific notation, for example, 5.3 x 106 (i.e., 5.3 millions). In this example, 5.3 is the mantissa, whereas 6 is the exponent. The situation is slightly more complicated, in that floating-point numbers used in computers are stored internally in binary. Some precision can be lost when converting between decimal and binary.Think of the floating-point number as a number in scientific notation, for example, 5.3 x 106 (i.e., 5.3 millions). In this example, 5.3 is the mantissa, whereas 6 is the exponent. The situation is slightly more complicated, in that floating-point numbers used in computers are stored internally in binary. Some precision can be lost when converting between decimal and binary.


Which procedure is used to convert a string representation of a number into its binary value?

The first step is to use a function to convert the number (integer, floating point or otherwise) into a string. The next step is to convert each character within that string to its binary equivalent. Converting an unsigned char to binary will require the use of bitwise operators, specifically &, << and >>. There are plenty of code snippets on the Web that show you how to accomplish this task, however it might be worth your while to work it out on paper first and then write the code. The best recommendation at this point is to explore bitwise operators in C and understand how binary math works. You'll likely find many uses for this knowledge in the future.


What is the c code for printing binary value of floating point values?

16


Floating point representation in binary why is it important to represent and how the decimal is placed in the binary?

It's a tricky area: Decimal numbers can be represented exactly. In contrast, numbers like 1.1 do not have an exact representation in binary floating point. End users typically would not expect 1.1 to display as 1.1000000000000001 as it does with binary floating point. The exactness carries over into arithmetic. In decimal floating point, 0.1 + 0.1 + 0.1 - 0.3 is exactly equal to zero. In binary floating point, the result is 5.5511151231257827e-017. While near to zero, the differences prevent reliable equality testing and differences can accumulate. For this reason, decimal is preferred in accounting applications which have strict equality invariants. So you have to be carefull how you store floating point decimals in binary. It can also be used in a fraction. It must be simplufied then reduced and multiplied.


What is a float value?

A value of float or floating point type represents a real number coded in a form of scientific notation. Depending on the computer it may be a binary coded form of scientific notation or a binary coded decimal (BCD) form of scientific notation, there are a nearly infinite number of ways of coding floating point but most computers today have standardized on the IEEE floating point specifications (e.g. IEEE 754, IEEE 854, ISO/IEC/IEEE 60559).


What is the utility of floating point representation of numbers?

A floating point number is, in normal mathematical terms, a real number. It's of the form: 1.0, 64.369, -55.5555555, and so forth. It basically means that the number can have a number a digits after a decimal point.


What are the rules in converting binary numbers to decimal numbers?

25 and nothing that had a decimal point well the number 369.3125 decimal. to convert to binary it worked fine the whole number 369 by justnumber by just dividing the desired base so since i wanted binary


How do you represent floating point number in microprocessor?

It is somewhat complicated (search for the IEEE floating-point representation for more details), but the basic idea is that you have a few bits for the base, and a few bits for the exponent. The numbers are stored in binary, not in decimal, so the base and the exponent are the numbers "a" and "b" in a x 2b.


What are the 3 parts of a floating part number?

If you mean floating point number, they are significand, base and exponent.


Benefits of using floating point arithmetic over fixed point arithmetic in CPUs?

Fixed point number usually allow only 8 bits (32 bit computing) of binary numbers for the fractional portion of the number which means many decimal numbers are recorded inaccurately. Floating Point numbers use exponents to shift the decimal point therefore they can store more accurate fractional values than fixed point numbers. However the CPU will have to perform extra arithmetic to read the number when stored in this format. Fixed point number usually allow only 8 bits (32 bit computing) of binary numbers for the fractional portion of the number which means many decimal numbers are recorded inaccurately. Floating Point numbers use exponents to shift the decimal point therefore they can store more accurate fractional values than fixed point numbers. However the CPU will have to perform extra arithmetic to read the number when stored in this format.