码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2016-12-10 13:57:04      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:ted   pre   power   float   echo   read   binary   ati   root   

#! /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工具实现数值转换(浮点转二进制)

标签:ted   pre   power   float   echo   read   binary   ati   root   

原文地址:http://www.cnblogs.com/leonarcohen/p/6155415.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!