18 May 2017

A C puzzle

Consider the following C code:

#include <stdio.h>

enum bitmask
    bitmask_A = 1,
    bitmask_B = 2,
    bitmask_C = 4
typedef enum bitmask bitmask;

struct a_s
    bitmask member;
typedef struct a_s a_t;

f(a_t *arg)
    arg->member |= bitmask_B;
    return bitmask_C;

    a_t foo;
    foo.member = bitmask_A;
    foo.member |= f(&foo);
    printf("%d\n", foo.member);
    return 0;
What happens?

30 January 2017

A Silly Physics Problem

Brought to you by Tyler Christensen

If you have two ideal 1F capacitors, one at 0V and one at 10V, and you connect them together instantaneously with an ideal superconductor, what is the final voltage? Note all components have zero physical size and there is zero parasitic inductance.