在bc中除法时如何得到十进制数? [英] How to get a decimal number when dividing in bc?

查看:29
本文介绍了在bc中除法时如何得到十进制数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用 'bc' 来划分一个数,不仅要给我底数,还要给我余数.例如,如果我做 '5/2','bc' 会给我 '2'.我真的想要像2.5"这样的东西

I need 'bc' to divide a number and give me not only the floor but also the remainder. For instance 'bc' gives me '2' if I do '5/2'. I'd really want something like '2.5'

也许这根本不可能?

推荐答案

scale = 20

它设置小数位数.

$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
355/113
3
scale=20
355/113
3.14159292035398230088
quit
$

这篇关于在bc中除法时如何得到十进制数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆