[0] https://en.wikipedia.org/wiki/Bc_(programming_language)#Hist...
TIL this and a cool CSS trick.
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb729901041524823122snlbxq" | dc
I've never tried to understand what's really going on to produce the result, but also wouldn't really know where to start - maybe someone in HN's audience can enlighten me? :)Many GNU/Linux distros (at least Debian and RHEL) install neither `dc` nor `bc` by default, afaik.
echo '1033333377708482P' | dc
produces the same output using Unix dc but not in the GNU near-clone. (To understand why, you have to R the P as well as the M.) echo 'EGSZ%%%'|tr 'E-Z%' 'R-ZA-M!' [Monte Carlo approximation of Pi.
Registers:
u - routine : execute i if sum of squares less than 1
i - routine : increment register x
z - routine : iterator - execute u while n > m++
r - routine : RANDU PRNG
m - variable: number of samples
x - variable: number of samples inside circle
s - variable: seed for r
k - variable: scale for division
n - variable: number of iterations (user input)
]c
[lrx 2^ lrx 2^ + 1>i]su
[lx 1+ sx]si
[lu x lm 1+ d sm ln>z]sz
[0k ls 65539 * 2 31^ % d ss lkk 2 31 ^ /]sr
? sn
5dksk
1 ss
lzx
lx lm / 4*
p
$ dc pi.dc
100000
3.13372 156 is unimplemented
Is that a gnuism? 6582352
dpP
(at least we now know the error is old enough to be in octal)