3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers The default Integer type in Haskell provides for very large numbers ```> 2 ^ 100 1267650600228229401496703205376 > 2 ^ 200 1606938044258990275541962092341162602522202993782792835301376``` (there is also a more efficient and traditional Int type)

```

```

 3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers Floating-point arithmetic Traditional IEEE floating-point arithmetic is also available (with the usual caveats) ```> 2.3 ^ 5 64.36343 > \$\$ * 25.333 1630.51877```

```

```

 3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers Floating-point arithmetic Exact rational arithmetic Haskell provides exact rational numbers (written with an infix "%") as a safer alternative to floating-point ```> 51 % 3 17 % 1 > (51 % 3) * (2 % 5) 34 % 5```

```

```

 3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers Floating-point arithmetic Exact rational arithmetic Booleans and if expressions The usual boolean values are written with initial caps; the conditional construct is an expression, not a statement ```> if 3 < 2 then "oops" else "hurray!" "hurray!" > (if 3 < 2 then "oops" else "hurray!") ++ " arithmetic works!" "hurray! arithmetic works!" > (if 3 < 2 then (+) else (*)) 10 20 200```

```

```

 3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers Floating-point arithmetic Exact rational arithmetic Booleans and if expressions Pairs and tuples Unlike most languages, Haskell provides pairs and tuples as independent entities (e.g., to return multiple results) ```> fst (2, "foo") 2 > 17 `divMod` 3 (5,2)```

```

```

 3rd CCSC Northwest Conference • Fall 2001

 Ints and Integers Floating-point arithmetic Exact rational arithmetic Booleans and if expressions Pairs and tuples The Maybe type The Maybe datatype marks values as either Nothing or "Just" a single value; this allows for a natural light-weight exception mechanism ```> lookup "sam" [("amy", 25), ("fred", 1), ("sam", 2)] Just 2 > lookup "jim" [("amy", 25), ("fred", 1), ("sam", 2)] Nothing```

```

```