[Scheme入門]2 算數運算,scheme算數

來源:互聯網
上載者:User

[Scheme入門]2 算數運算,scheme算數

1、quotient、remainder、modulo和sqrt

函數quotient用於求商數(quotient)。

函數remainder和modulo用於求餘數(remainder)。

函數sqrt用於求參數的平方根(square root)。

以下是一些樣本:

(quotient73)

;Value: 2

(modulo73) 

;Value: 1
(sqrt 10)  

;Value: 3.1622776601683795


2、sin、cos、tan、asin、acos和atan

atan接受1個或2個參數。如果期望atan的結果是1/2 π,就使用第二個參數指明使用弧度制。

以下依舊是一些樣本:

(atan1) 

;Value:0.7853981633974483
(atan 1 0)

;Value:1.5707963267948966

(* 4 (atan 1.0))

;Value: 3.141592653589793


3、指數和對數

指數通過exp函數運算,對數通過log函數運算。a的b次冪可以通過(expt a b)來計算。

(exp 2/3)

;Value: 1.9477340410546757

(expt 3 4)

;Value: 81

(log 1000)

;Value: 6.907755278982137


4、幾種數值的變換

函數exact->inexact用於把分數轉換為浮點數。

(exact->inexact(/293 7))

;Value:1.380952380952381



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.