Chapter 5. Performing Numerical Calculations

On two occasions I have been asked [by members of Parliament], “Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?” I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

—Charles Babbage

Numeric data is the original data type, the native language of the computer. We would be hard-pressed to find areas of our experience where numbers are not applicable. It doesn’t matter whether you’re an accountant or an aeronautical engineer; you can’t survive without numbers. We present in this chapter a few ways to process, manipulate, convert, and analyze numeric data.

Like all modern languages, Ruby works well with both ...

Get The Ruby Way: Solutions and Techniques in Ruby Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.