Answers:
您可以使用设置小数部分的长度scale=n
。
该命令echo 'scale=20;752/447' | bc
产生:
1.68232662192393736017
请注意,即使数字适合刻度,也可能会附加其他零:
scale=20
1/2
.50000000000000000000
不幸的是,总是存在一个四舍五入的问题:
scale=50
1/3*3
.99999999999999999999999999999999999999999999999999
scale
变量传递给bc
。唯一的环境变量可能是有用的BC_ENV_ARGS
。该变量bc
带有一些参数,您可以使用标准变量或设置创建一个文件,然后设置BC_ENV_ARGS=/path/to/variables/file
。请阅读手册页。
bc -ql
。-q
隐藏版权标语(通常证明会分散注意力)并-l
加载数学库,并自动将标度设置为20。(请参阅man bc
。)
calc
(我相信来自package apcalc
)与相同bc
,但不舍入。它的显示方式bc
与相似,但与有所不同bc
,它理解科学计数法。例:
> calc
C-style arbitrary precision calculator (version 2.12.3.3)
Calc is open software. For license details type: help copyright
[Type "exit" to exit, or "help" for help.]
; a=234
; b=a/7
; b
~33.42857142857142857143
; c=b/1e20
; c
~0.00000000000000000033
; c*1e10
~0.00000000334285714286
;
与bc
:
> bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
a=234
b=a/7
b
33.42857142857142857142
c=b/10^20
c
.00000000000000000033
c*1e10
(standard_in) 6: syntax error
c*10^10
.00000000330000000000
稍作搜索就会发现很多结果,但并非所有结果都是相关的,但是我敢肯定,通过一些试验,您可以确切地找到想要的结果(例如wcalc):
aptitude search calc
i apcalc - Arbitrary precision calculator (original name: calc)
i A apcalc-common - Arbitrary precision calculator (common files)
p apcalc-dev - Library for arbitrary precision arithmetic
p bandwidthcalc - file transfer time calculator written in GTK+
p calcoo - Scientific calculator (GTK+)
p calcurse - text-based calendar and todo manager
p concalc - console calculator
p extcalc - multifunctional scientific graphic calculator
p gcalcli - Google Calendar Command Line Interface
i gcalctool - GNOME desktop calculator
p ipcalc - parameter calculator for IPv4 addresses
p ipv6calc - small utility for manipulating IPv6 addresses
p kcalc - calculator for KDE 4
p keurocalc - universal currency converter and calculator - binary package
p keurocalc-data - universal currency converter and calculator - data package
p lcalc - a program for calculating with L-functions
p libcolor-calc-perl - Perl module for simple calculations with RGB colors
p libdate-calc-perl - Perl library for accessing dates
p libdate-pcalc-perl - Perl module for Gregorian calendar date calculations
p libmath-basecalc-perl - Convert numbers between various bases
p libmath-calc-units-perl - Human-readable unit-aware calculator
p libmath-calculus-differentiate-perl - Algebraic Differentiation Engine
p libmath-calculus-expression-perl - Algebraic Calculus Tools Expression Class
p libmath-calculus-newtonraphson-perl - Algebraic Newton Raphson Implementation
p libticalcs-dev - Texas Instruments calculator communication library [development files]
p libticalcs2-7 - Texas Instruments calculator communication library
p libwww-google-calculator-perl - Perl interface for Google calculator
p octave-physicalconstants - provide physical constants values in Octave
i openoffice.org-calc - office productivity suite -- spreadsheet
v openoffice.org2-calc -
p python-ipcalc - perform IP subnet calculations
v python2.6-ipcalc -
p r-cran-epicalc - GNU R Epidemiological calculator
p rpncalc - RPN calculator trying to emulate an HP28S
p science-numericalcomputation - Debian Science Numerical Computation packages
p sipcalc - Advanced console-based ip subnet calculator
p subnetcalc - IPv4/IPv6 Subnet Calculator
p sugar-calculate-activity - calculate activity for the Sugar graphical shell
p tapecalc - a full-screen tape editor that lets the user edit a calculation
p transcalc - microwave and RF transmission line calculator
p wcalc - A flexible command-line scientific calculator
p wmcalclock - A dock.app which simply tells time and date
p xsmc-calc - Smith Chart calculator for X
我建议使用Python作为命令行计算器:
$ python
>>> from math import *
>>> help(sin)
sin(x)
Return the sine of x (measured in radians).
我也建议使用IPython或IDLE。两者都极大地提高了标准外壳的可用性。
更新:使用python3避免截断意外:
$ python2.7
>>> 10/3
3
$ python3
>>> 10/3
3.3333333333333335
在这种意义上,您失去了精度:如果将precision设置为10个十进制数字,则除法将被截断为10个十进制数字,这是一个连贯的选择。
如果您要寻找一个精确的计算器,则需要一个符号系统maxima
。
顺便说一下,bc
支持变量。
“ genius”是目前最先进的计算器,具有命令行和GUI选项。有关详细信息,请查看手册,并参阅http://www.jirka.org/genius.html。
要安装,只需键入:
sudo apt-get install genius gnome-genius