1. 程式人生 > >shell指令碼之使用bc工具實現數值轉換(浮點轉二進位制)

shell指令碼之使用bc工具實現數值轉換(浮點轉二進位制)

#! /bin/bash
echo -n input float:
read num
echo power of the operation:
echo $num^2 |bc
echo converted to binary
echo "obase=2;$num" |bc
[[email protected] Desktop]# ./zhuanhuan.sh 
input float:3.1415926
power of the operation:
9.8696040
converted to binary
11.001001000011111101101001