BASH scripts can do floating point math!??? NAAAWWW!!!

Dec 01, 2014 6 Replies

Have fun, guys!


Run this BASH script to see your x terminal perform serious floating point operations! HAHAH!



save as BASHYBrot do this to time it



time . BASHYBrot



BASHYBrot follows:



#!/bin/bash



S0=B; S1=A; S2=S; S3=H; S4=Y; b=bc; I=-1



for x in {1..24} do R=-2 for y in {1..80} do B=0; r=0; i=0 while [ $B -le 32 ] do r2=$(echo "$r*$r" | $b) i2=$(echo "$i*$i" | $b) i=$(echo "2*$i*$r+$I" | $b) r=$(echo "$r2-$i2+$R" | $b) ((B+=1)) V=$(echo "($r2 +$i2)>4" | $b) if [ "$V" -eq 1 ]; then break fi done if [ $B -ge 32 ]; then echo -n " "; else U=$(((B*4) / 15+30)) echo -en "\E[01;$U""m" C=$((C%5)) eval "echo -ne \$E\$S$C" ((C+=1)) fi R=$(echo "$R+0.03125" | $b) done echo -e "\E[m\E(\r" I=$(echo "$I+0.08333" | $b) done


NOT! sudo `rm which bc`

umop apisdn

On Tue, 02 Dec 2014 15:25:36 +1100, Grant Gave us:

Naw, man... there's no fast fourier stuff in there! :-)

Yes... I know what it is. I was born 'before cells'.

On 2 Dec 2014 05:45:28 GMT, Jasen Betts Gave us:

SH SH SHHHH SHHHH SHHHHHH

BASH you upside yer dwnhaed.

On Wed, 03 Dec 2014 11:59:18 -0800, Mac Decman Gave us:

Yours?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required