HELP: uint16_t and >> operator used in following program

This is a discussion on HELP: uint16_t and >> operator used in following program within the C Programming forums, part of the General Programming Boards category; what does "uint8_t" or "uint16_t" mean? Can you tel me output of following statement if you can then please explain ...

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    HELP: uint16_t and >> operator used in following program

    what does "uint8_t" or "uint16_t" mean?
    Can you tel me output of following statement if you can then please explain ?

    TWI_SLA_CAM=0xC0
    uint8_t sla;
    uint16_t eeaddr=0x12;
    sla = TWI_SLA_CAM |(((eeaddr >> 8) & 0x07) << 1);

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    uint8_t is unsigned type containing 8 bits (on most compilers unsigned char will do)
    uint16_t is unsigned type containing 16 bits - on most compilers unsigned short will do the work

    What do YOU think will be the output?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    3

    Unhappy

    i am not able to get wat
    "eeaddr>> 8"
    do ,bcoz eeaddr =0x12 even after being uint16_t

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Mar 2009
    Posts
    3
    I am unable to figure out how a uint16_t eeaddr be shifted to right by 8 bits, becoz the value stored in eeaddr is 0x12, thus shifting it by 8 bits gives 0.
    and finally gives sla=0xc0; that is TWI_SLA_CAM

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by pvr_3 View Post
    I am unable to figure out how a uint16_t eeaddr be shifted to right by 8 bits, becoz the value stored in eeaddr is 0x12, thus shifting it by 8 bits gives 0.
    and finally gives sla=0xc0; that is TWI_SLA_CAM
    So? What is the problem with this? Seems to be correct analisys.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. overloaded >> operator problem
    By quizkiwi in forum C++ Programming
    Replies: 7
    Last Post: 07-19-2005, 03:27 PM
  2. C++ >> Standard Library >> Header File
    By hrk2006 in forum C++ Programming
    Replies: 2
    Last Post: 06-24-2003, 08:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21