Thread: data types

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    9

    data types

    my query s about data types .........
    int 2 byte (means 16 bit) so how the dATAS ARE STORING I NEED CLEAR EXPLANATION
    NOT ONLY INT FOR CHAR ,FLOAT,LONG ,DOUBLE SHORT ........ THEN SIGNED ,UNSIGNED.........

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Theyre stored in ram or on disk. Same with all the other types. If thats not a "clear explanation" then you have to ask your question clearly.

    Are you asking how these bytes are represented in memory, theyre byte order? See this link which has a few simple pictures for types of endian. Also, review that whole page, not just the pictures there. Endianness - Wikipedia, the free encyclopedia

  3. #3

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Well, a 16-bit integer is stored as a binary value 16 digits long. So is a (16-bit) float. A char (1 byte) is also stored as a binary value.

    See the ASCII Table / Extended ASCII Codes for a better understand of how a char "letter" is stored as a numerical value.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User slingerland3g's Avatar
    Join Date
    Jan 2008
    Location
    Seattle
    Posts
    603
    On a side note, review little endian and big endian may help as well here. The actual placement of MSB is important on some systems especially in transfering bits across the network. Something to think about.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    75
    Quote Originally Posted by MK27 View Post
    Well, a 16-bit integer is stored as a binary value 16 digits long. So is a (16-bit) float. A char (1 byte) is also stored as a binary value.

    See the ASCII Table / Extended ASCII Codes for a better understand of how a char "letter" is stored as a numerical value.
    Since when there are 16 bits floats?

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by MisterIO View Post
    Since when there are 16 bits floats?
    Aren't there? It doesn't matter. My point was a 16-bit float would be a 16 digit binary number, just like a 32-bit float is a 32 digit binary number.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by britto116 View Post
    my query s about data types .........
    int 2 byte (means 16 bit)
    I haven't seen a 16-bit int since 1995. Are you really still running DOS??
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  9. #9
    Registered User
    Join Date
    Nov 2008
    Posts
    75
    Quote Originally Posted by cpjust View Post
    I haven't seen a 16-bit int since 1995. Are you really still running DOS??
    I guess he's talking about short ints.

  10. #10
    Registered User
    Join Date
    Nov 2009
    Posts
    9

    c data types

    Quote Originally Posted by nadroj View Post
    Theyre stored in ram or on disk. Same with all the other types. If thats not a "clear explanation" then you have to ask your question clearly.

    Are you asking how these bytes are represented in memory, theyre byte order? See this link which has a few simple pictures for types of endian. Also, review that whole page, not just the pictures there. Endianness - Wikipedia, the free encyclopedia
    clear view s....... int x= 5 is valid but int x=50000 is not valid y?........ ie bytes how they r converting and how it stores in memory .....

  11. #11
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    [Range of 'int']: Signed: −32,768 to +32,767, Unsigned: 0 to +65,535 (source: http://en.wikipedia.org/wiki/Integer...ter_science%29). I believe by "default", types are signed. So 'int y =50000' overflows the maximum value that a signed 'int' can store, so you would need to make it an 'unsigned int y=50000' instead.

    bytes how they r converting and how it stores in memory .....
    I still dont understand what your asking. Did you read the link I posted about Endianness? That shows how the bytes are stored in memory.

  12. #12
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Data storage in memory is depends on the hardware and OS you are using

    lets say i am using a 32 Bit OS on a 32 Bit Machine i think which normally available with all of us now a days. Now 64 Bit Machines and OS are also coming.

    And it also depends which endianess machine is :----

    For Little indian

    char will be stored in i Byte means 8 bit lets say you want to store 'A'

    then it will be stored in memory like 1000001

    and if it will be int then it will take normally 4 bytes for float and long also it will take this much of bytes.

    And the value will be store in 32 bits ..... for max value u can just do 1 << 32

    But in case of big endian

    the MSB will be stored at lower address and in little endian the MSB will stored at higher address this causes the problem in conversion from one to another.....

    You also have to look at how the structures are adjusted into the memory and just google the structure padding you will get to know about this also

  13. #13
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by RockyMarrone View Post
    Now 64 Bit Machines and OS are also coming.
    You mean already here. I'm running Vista x64.

    Quote Originally Posted by RockyMarrone View Post
    For Little indian
    I heard that's a pretty good restaurant.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 03:28 PM
  2. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 06:26 PM