CS151, Class 8: Numbers Overview: * Types in Scheme * Numeric Types in Scheme * Lab * Reflection Administrivia: * Feel free to use computers during my 10:00-10:50 class and my 3:15-4:05 class. * Read "Defining Procedures in Scheme" * Have a good weekend. ---------------------------------------- Types in Scheme * Almost every computer language assigns a "type" to values * "Type" says what kind of information the value is: symbol, number, procedure * Why do we have types? + Permits it the computer to understand underlying "bits" + Helps programmers "do the right thing" * Many kinds of numbers in Scheme + Exact / Inexact Precisely represented / Probably approximated + Integer, Rational, Real, Complex * Lots of built-in numeric procedures + sqrt, expt, + , -, *, / + quotient, remainder, mod, numerator, denominator, ... * Predicates for checking kinds of numbers + integer? rational? real? complex? + even? odd? + exact? inexact? REFLECTION * "1.507 times 10 to the fifteenth power" 1.507e15 * "as an exact number" #e1.507e15 * Alternatively ... (* 1507 (expt 10 12)) * #e can only go in front of numbers, not expressions * What does (round (+ i 1/2)) do for integer i? * Quotient and remainder: * What is (numerator 1.3) 1 + XXXXX/(expt 2 52) > (inexact->exact #i13/10) 1 1351079888211149/4503599627370496 Isn't that thrilling?