File: byte.cc

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (34 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <cstddef>

#include <cstdint>          // uint8_t

using namespace std;

//ostream &operator<<(ostream &out, uint8_t value)
//{
//    return out << static_cast<uint16_t>(value);
//}

int main()
{
//    uint8_t u8 = 40;         // works great!
//    cout << u8 << '\n';

//init
    byte value{ 0x23 };     // #1 (see the text above)
//  byte error{ 0x123 };    // #2

    char ch = 0xfb;
//  byte error{ ch };       // #3

    byte b1 = byte( ch );   // #4
    value = byte( 0x123 );  // #5
//=

//    cout << (value == byte{ 0 }) << '\n';
//    cout << hex << static_cast<size_t>(value) << '\n';

    if (value > b1)
        value &= byte(0xf0);
}