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
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <stdint.h>
#include "print_bits.h"

int main(int argc, char* argv[]) {
    uint8_t byte = 0xa8;
    printf("%x\n", byte); 
    printf("%ld\n", sizeof(byte)); 
    
    log_bits(byte);


    // 0110 1001
    uint8_t a = 0x69;
    // 1011 0101
    uint8_t b = 0xb5;
    log_bits(a);
    log_bits(b);
    log_bits(a & b);
    log_bits(a | b);
    log_bits(a ^ b);
    log_bits(~a);
    log_bits(-a);

    uint8_t unsigned_byte = 0xa8;
    log_bits(unsigned_byte);
    log_bits(unsigned_byte >> 2);
    log_bits(unsigned_byte << 2);
    int8_t negative_signed_byte = -0x58;
    log_bits(negative_signed_byte);
    log_bits(negative_signed_byte >> 2);
    log_bits(negative_signed_byte << 2);
    int8_t positive_signed_byte = 0x58;
    log_bits(positive_signed_byte);
    log_bits(positive_signed_byte >> 2);
    log_bits(positive_signed_byte << 2);

    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2024 Alexander J. Quinn & David Burnett         This content is protected and may not be shared, uploaded, or distributed.