how the size of an integer is decided?
- is it based on processor or compiler or OS?
Answers were Sorted based on User's Feedback
Answer / prashant
It depend upon What kind of machine you have (16 or 32 bit)?
If you are using 16 bit machine then int requires 2 bytes of
memory and if you are using 32 bit machine then int requires
4 bytes of memory...
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / vishal
In this case,
Processor : now if we consider size of ALU (16 bit or 32
bit) then int size get differed.
OS: in case of OS size of int varies in windows & linux.
Compiler : In case of compiler, C compiler has size of int 2
bytes while on same OS & processor Java compiler has 4 bytes
Finally conclusion is as per operation capacity of ALU,
operating systems are designed.
while in case of compiler i think they work in somewhat
upper layers so it doesn't matter with internal operation.
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / hrishikesh
I think it is decided by Os...
Because variables are assigned memory while the program is
in execution which is done by the OS,and the "MEMORY
MANAGEMENT" is one of the important services provided by the
OS which does the "memory allocation and De allocation".
So, what will be the amount of location needed to store an
int is OS dependent .
Thanks ....,,,,
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / mrutyunjay sawant
its depends upon word length of processor
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / rani
I think its compiler specific bcoz a char holds 1byte in c
where as it holds 2 bytes in java.
Is This Answer Correct ? | 3 Yes | 8 No |
Answer / rahul
definitely os bcoz.c compiler occupies 2 bytes in windows
where as the same c compiler occupies 4 bytes in linux.
Is This Answer Correct ? | 3 Yes | 11 No |
Answer / rajan
it's OS, I'm sure bcoz I read this answer in Programming
Interview Exposed Book.
Is This Answer Correct ? | 1 Yes | 13 No |
helllo sir , what is the main use of the pointer ,array ,and the structure with the example of a programe
How to write c functions that modify head pointer of a linked list?
Why static is used in c?
Given an array of characters, how would you reverse it? How would you reverse it without using indexing in the array?
What is the difference between printf and scanf )?
What is dynamic memory allocation?
which is an algorithm for sorting in a growing Lexicographic order
Why cann't whole array can be passed to function as value.
Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer...
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
What does the file stdio.h contain?
Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors