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

  

posted on 2016-12-10 12:51  leonardhelloworld  阅读(854)  评论(0编辑  收藏  举报

导航