首页 > 代码库 > 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

  

[root@lenny Desktop]# ./zhuanhuan.sh 
input float:3.1415926
power of the operation:
9.8696040
converted to binary
11.001001000011111101101001

  

shell脚本之使用bc工具实现数值转换(浮点转二进制)