O'Reilly logo

Thinking Functionally with Haskell by Richard Bird

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3

Numbers

Numbers in Haskell are complicated because in the Haskell world there are many different kinds of number, including:

Intlimited-precision integers in at least the range

[−229, 229). Integer overflow is not detected.

Integerarbitrary-precision integers

Rationalarbitrary-precision rational numbers

Floatsingle-precision floating-point numbers

Doubledouble-precision floating-point numbers

Complexcomplex numbers (defined in Data.Complex)

Most programs make use of numbers in one way or another, so we have to get at least a working idea of what Haskell offers us and how to convert between the different kinds. That is what the present chapter is about.

3.1 The type class Num

In Haskell all numbers are instances of the type class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required