Bc

From CleanPosts

Jump to: navigation, search

Convert a floating point number to binary

echo 'obase = 2; scale = 15; 3.141592653589793' | bc -l

Convert temperatures

#!/bin/bash
c=$(echo "scale=1;($1-32)*(5/9)" | bc -l)
f=$(echo "scale=1;($1*(9/5))+32" | bc -l)
echo -e "\n\e[1;30m=$c C & $f F\e[0m\n"

Factorial function implemented by recursion

define fact(n) { if (n <= 1) return (n); return (n * fact(n-1)); }

Personal tools
Strangers In Paradise