The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
247 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 (421 points) | 247 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 Boss (17.8k points)
0
i think you are telling big endian representation.
0

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


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

34,780 questions
41,755 answers
118,921 comments
41,399 users