The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
229 views
I saw on http://www.cquestions.com/2009/06/memory-representation-of-int-data-type.html  but it seems wrong to me. Please clarify.
asked in Programming by (445 points) | 229 views

2 Answers

+1 vote

That is correct except for one extra 1 which seems to be a typo. 

0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

This will be the representation of int a = 7, assuming sizeof int is 4 bytes and a little endian machine (start address of memory is from the left).

Why is there a confusion?

 

answered by Veteran (14.6k points)
i think you are telling big endian representation.

No. Its little endian. The least significant byte occupies the first byte of the address. In big endian, the most significant byte occupies the first byte of the address. int a = 7 in big endian will be
 

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

 

0 votes

Related questions

+2 votes
0 answers
1
asked in CO & Architecture by Hemant Parihar Veteran (13.2k points) | 74 views
+1 vote
1 answer
2
asked in Databases by Arjun Kumar 1 (129 points) | 75 views
+1 vote
3 answers
3


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

32,694 questions
39,293 answers
110,109 comments
36,701 users