Unix下该如何进行常用数学计算?
Linux/Unix下该如何进行常用数学计算?
用shell中的万能的awk 看一些简单的事例: [oracle@asm tmp]$ gdb GNU gdb Red Hat Linux (6。3。0。0-1。63rh) Copyright 2004 Free Software Foundation, Inc。
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions。
Type "show copying" to see the conditions。 There is absolutely no warranty for GDB。 Type "show warranty" for details。 This GDB was configured as "i386-redhat-linux-gnu"。
(gdb) p 1。4*123。324*3 $1 = 517。96079999999995 (gdb) p /x 1。4*123。324*3 $2 = 0x205 (gdb) p /x 4*24 $3 = 0x60 (gdb) [oracle@asm tmp]$ echo | awk '{print 1。
1*2*23。34;}' 51。348 [oracle@asm tmp]$ awk 'BEGIN {print (1。25^10);}' 9。31323来源:www。examda。com awk 支持不少常见的运算符, 如: + (加),- (减), * (乘), / (除), ^ 或 **(乘方), % 取模) 等等。
此外, awk 也提供了一些常用的数学函数, 比如 sin(x), cos(x), exp(x), log(x), sqrt(x), rand()。 使用这些运算符和函数可以直接进行一些简单的运算: [oracle@asm tmp]$ echo | awk '{print sin(2);}' 0。
909297 。
答:你个鸟人详情>>