For some reason, I was using calc all this time. I mean, it’s good, but I need to do base conversions (dec, hex, bin) very often and you have to type base(2)
or base(16)
in calc to do that. That’s exhausting after a while.
So I now replaced calc with a little Python script which always prints the results in dec/hex/bin, grouped in bytes (if the result is an integer). That’s what I need. It’s basically just a loop around Python’s exec()
.
$ mcalc
> 123
123 0x[7b] 0b[01111011]
> 1234
1234 0x[04 d2] 0b[00000100 11010010]
> 0x7C00 + 0x3F + 512
32319 0x[7e 3f] 0b[01111110 00111111]
> a = 10; b = 0x2b; c = 0b1100101
10 0x[0a] 0b[00001010]
> a + b + 3 * c
356 0x[01 64] 0b[00000001 01100100]
> 2**32 - 1
4294967295 0x[ff ff ff ff] 0b[11111111 11111111 11111111 11111111]
> 4 * atan(1)
3.141592653589793
> cos(pi)
-1.0