Linux計算器運算的程序文件
你們知道什么是Linux計算器么這個非常高深的運用技術將由我來非常講解,Linux計算器NB在哪呢,下面我來進入講述Linux計算器的無限領域。
19--bc Linux計算器
[root@CentOS4 ~]# bcbc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'. (interrupt) use quit to exit.(interrupt) use quit to exit.quit[root@CentOS4 ~]# Linux計算器在bc上常用的運算符有:+加法-減法*乘法/除法(在沒有設置scale精確度時候,自動取整)^指數(shù)%求余數(shù)(取模)在bc上還可以使用++ 變量-- 變量 變量 ++ 變量 --
[root@CentOS4 ~]# bcbc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'. 1+23234+23/2*326725^315625100%40100%238quit[root@CentOS4 ~]# [root@CentOS4 ~]# bc bc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'. scale=2 /*scale=number*/11/42.7511/33.66quit[root@CentOS4 ~]#
Linux計算器說明:scale=2 是設置小數(shù)精確度。/*備注部分*/
bc還可以運行一個Linux計算器帶有復雜運算的程序文件(這屬于bc的一個擴展屬性),如:The following is code that uses the extended features of bc to implement a simpleprogram for calculating checkbook balances. This program is best kept in a file so that it can be used many times withouthaving to retype it at every use.
Linux計算器使用vi建立一個test運算程序:root@CentOS4 ~]# vi testscale=2print ""nCheck book program!"n"print " Remember,deposits are negative transaction."n"print "Initial balance?";bal=read()bal /= 1print ""n"while (1){"current balance = ";bal"transaction?";trans =read()if(trans == 0) break;bal -= trans bal /= 1}
"test" [New] 14L, 268C written[root@CentOS4 ~]# ls計算結果:[root@CentOS4 ~]# bc "testbc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty'. Check book program!Remember,deposits are negative transaction.Initial balance?560current balance = 560.00transaction?400current balance = 160.00transaction?100current balance = 60.00transaction?0quit[root@CentOS4 ~]#
今天Linux計算器就學到這些,發(fā)現(xiàn)很多內(nèi)容非常的有意思。就近來的學習總結出,要想學好Linux計算器,重要一點是英語要學好。雖然大致的意思能看明白,但很吃力,經(jīng)常金山詞霸來查某一個單詞的意思,這樣往往浪費了很多的時間在解決單詞的意思。
【編輯推薦】