lecture29-apr9 - Lecture 29 Announcements Monday lectures...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
4/9/10 1 Lecture 29 Announcements Monday lectures cancelled Exam 2 - back High = 99 Low = 17.5 Median = 74.5 Average = 73.5 Assignment 6 – Q&A Last time we learned how to: Shift bit values left and right Set, clear, toggle and test Single bits within a value Bit fields within a value Topics of the day More Low level programming Bit structure operations Examples – parity checker Swap the bytes example unsigned short int i , high_byte, low_byte; scanf (“%hu”, &i); high_byte = i << 8; low_byte = i >> 8; i = high_byte | low_byte; Other ways??? Rotate i by 8 bits (left or right) ?? unsigned short int rotate(unsigned short int value, int numbits, char direction); How do you swap the upper and lower bytes of a 16 bit value ? Bit-Fields in Structures A structure may contain bit-fields—members whose size is specified as some number of bits. E.g. some OS’s stores file dates as struct file_date { unsigned int day: 5; unsigned int month: 4; unsigned int year: 7; /* last 2 digits of year – e.g. 2010 -> 10 */ }; The order in which bit-fields are allocated within a storage unit depends on the implementation (e.g.Visual C/C++ allocates right to left). Basic storage units are typically bytes and words A bit-field can be used just like any other element of a structure:
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern