how integer stored in binary format in 'c' language, plz give detail internal structure
how integer stored in binary format in 'c' language, plz give detail internal structure
as zeros and ones ofcourse...
if you wish to know how a c program is compiled linked and loaded and executed then see this link
Hello World Program
Code:printf("%c%c%c%c%c%c%c",0x68,0x68^0xd,0x68|0x4,0x68|0x4,0x68|0xf,0x68^0x49,0x68^0x62);
The format of an integer is determined by the machine architecture - the C standard does make quite sure that as long as some BASIC criteria is met (e.g. that there are signed and unsigned numbers [that can be either positive or negative]). There are also some minimum requirements for size/range. But how the bits are ordered and how their values are actually interpreted is up to the compiler and hardware architecture to deal with.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
isn't that the int,char will be stored in the binary of ASCII(or other type of encoding)value of that particular integer.for eg if ASCII of 1 is 49 so 1 should be internally stored as binary of 49.
No, an integer with the value of 1 will be stored as a bunch of zeros and a single 1 [in the common way that MOST processors use, at least]. If you have a char of the value '1' [in a common ASCII machine], then the value would be 49 decimal. But a char can also have the value 00000001, which is the same as the integer value 1. It also (again, in ASCII) corresponds to CTRL-A.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
i'm getting confused.the ASCII value of '1' is 49 decimal.if 1 is not getting stored as binary of 49 then what's the use of ASCII.'1' can be equally written as 49 then why ASCII codes have been made.what ASCII does at all.plz clear my confusion.
Thanks
The TEXT CHARACTER '1' has the value 49. The number 1 as stored in an integer [and for all intents and purposes, char is a tiny integer] is not the same as '1' stored in memory. It is stored as 00000001 - the number of zeros vary depending on what size integer it is, but the binary value is always [at least for all machines I know of] a load of zeros (logically) to the left of a single 1.
When you write int x = 1, the a value consisting of (say) 31 zeros and a single 1 will be stored in the location that represent x. If you do x = '1' then the value 49 decimal, 0000...00110001 in binary will be stored there.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Thanks again matsp.you cleared my doubt.