
Programmer's Calculator - gregorymichael
https://www.embeddedrelated.com/showarticle/1061.php
======
kazinator
POSIX syntax, entered into BusyBox shell (not even Bash or anything), running
__on__ an ARM embedded system:

    
    
      # echo $(( (0x0110 << 14) & 0xDEADBEEF ))
      262144
      # printf "%x\n" 262144
      40000
    

Now let's make a calculator REPL out of these:

    
    
      # while read expression ; do eval "result=\$(( $expression ))"; printf "dec = %d, hex = %x\n" $result $result ; done
      2 + 2
      dec = 4, hex = 4
      a=3
      dec = 3, hex = 3
      b=4
      dec = 4, hex = 4
      a + b
      dec = 7, hex = 7
      (a + b) << 3 
      dec = 56, hex = 38
      [Ctrl-D][Enter]
      #

