Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know if the chart helps, but

    #define CTRL(x) ((x) ^ 0100)
    // e.g. 'C' ^ 0100 is 3
    // e.g. '@' ^ 0100 is 0
    // e.g. 'M' ^ 0100 is 13 a.k.a. \r a.k.a. enter
I like this explanation better. It also explains what notation like ^C means. It's shorthand for 0100^C.


Expanding your overloaded operator:

Crtl-C is shorthand for 0100 xor ā€˜C’

Also, the 0 prefix means this is a base-8 (octal) number




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: