7. Summary

The chapter is about doing math with numbers.

Essential summary

(+ 5 3)
(/ 13 7) ; thirteen divided by seven
(* 11 2)
(- 9 1) ; nine minus one
(- 8)
(quotient 21912 7)
(remainder 21912 7)
(expt 1.01 95) ; 1.01 to the 95 power is about 2.57
(sqrt 9) ; square root of 9 is three
(sqr 1241) ; when you square 1241 you get 1540081
> (sqrt 5) ; about 2.236
#i2.23606797749979

The #i at the start of #i2.236... means that the number is an “inexact” decimal. You should never use check-expect with inexact numbers, because the inexact results can be different on different computers! Instead, use check-within.

(check-within (sqrt 5) 2.236 0.001)
> pi
#i3.141592653589793
(max 0 -4) ; ==> 0
(min 255 300) ; ==> 255
(abs -10) ; ==> 10
(real->int 0.5)
(real->int 1.5)
(real->int 2.5)
(ceiling 1.2)
(floor 1.7)
(round 1.6)

More Important Ideas