# Converting Floating Point Number to a Binary Number

Hi guys, my first ever post.

I want to convert a floating point number such as 3.1147 to 11.0001110101011101. Has anyone attempted this before in Arduino?

Has anyone attempted this before in Arduino

Perhaps, but it only makes sense if you do it yourself

I'd consider this a very proprietary format. ( 1.1 probably means 20+2-1 = 1.510 ?)

Ablai:
Hi guys, my first ever post.

I want to convert a floating point number such as 3.1147 to 11.0001110101011101. Has anyone attempted this before in Arduino?

wonder what you mean...

by that what I try to say is that if in arduino you create a variable 'float x = 3.1147' after compile time that value is store in the processor as a binary number! how it's stored is a whole different matter but its in zeros and ones!

Ablai:
Hi guys, my first ever post.

I want to convert a floating point number such as 3.1147 to 11.0001110101011101. Has anyone attempted this before in Arduino?

That's what it already is. So you must be talking about a print routine.

In the school, when the pupils are asked to find the binary equivalent of 3.1147 using paper-pencil, they will come up with 11.0001110101011101.

In the machine, when a computer is asked to find the binary equivalent of 3.1147 using binary32/IEEE-754 standard (Fig-1), it will come up with 0100 0000 0100 0111 0101 0111 0011 1111 (0x4047573F). In the school, the students can also use the given template of Fig-1, and they will come up with the same result.

Figure-1: binary32/IEEE-754 Standard for the 32-bit binary value of a floating point number

Storing digital data in a "float" built from positive and negative powers of 2 is common. It is used in the temperature registers of the DS3231 and the DS18B20.

Having the smallest increment being 2 exp -16 is unusual.

(hit and run) OP: It is stored as a mantissa and exponent. But my point was that you can easily construct 11.0001110101011101 from that. I didn't see where you specified whether the decimal was fixed or not.