Back to articles
Programming foundation - data types at bit level

Programming foundation - data types at bit level

via Dev.to TutorialBimsara

welcome to this sub article,in here I'm going to talk about data types for little deeper, Okay,computers store data as 1 and 0 , we call them 'bit'.when we define data type as int,float etc. we define how much bits that value need, int this can be either 16 bits or 32 bits depending on the system meaning when we store a value as a int,memory will allocate 16 or 32 bits for that value eg: int age=25 if we convert 25 into bits Division Quotient Remainder 25 ÷ 2 12 1 12 ÷ 2 6 0 6 ÷ 2 3 0 3 ÷ 2 1 1 1 ÷ 2 0 1 Reading the remainders from bottom to top gives us 11001. So 25 is stored as: 16-bit: 00000000 00011001 32-bit: 00000000 00000000 00000000 00011001 float this is for storing decimal numbers and float data type will allocate 32 bits in memory 1 bit for sign bit 8 bits for exponent 23 bits for Mantissa eg: float a= 20.5 let's represent this in bits first the 20 Division Quotient Remainder 20 ÷ 2 10 0 10 ÷ 2 5 0 5 ÷ 2 2 1 2 ÷ 2 1 0 1 ÷ 2 0 1 20 => 10100 then .5 Multiplication result Integ

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles