Previously we discussed the mathematical foundations of computer integers and found that, as far as arithmetic is concerned, we can choose to use any range of N = 2m numbers, and the arithmetic operations that have to be implemented in hardware are not affected. Why is it then that in most programming languages we are …
Category Archives: Mathematics
Mathematics of computer integers
Integers have typically a fixed size in computers, for example 32 or 64 bits. Since there are no such limits on the size of integers in mathematics, the question arises: how do computer integers work, with respect to mathematical theory?
Positive and negative zeros, and MySQL
In mathematics, zero is usually considered without a sign. It’s neither positive nor negative. In computer floating point numbers there are two zeros: one positive, +0.0, and one negative -0.0, at least if we follow the IEEE standard.
Converting decimal numbers to fractions
Given that computer numbers have a finite precision, a calculation like 20/3 produces a result like 6.66667, which is slightly off. This begs the question: can we reverse the division operation, to make a routine that outputs “20/3” when it’s given the approximate value? One trick is to take a large number as the denominator. …
An Interesting Golden Ratio Identity
Lately I’ve been intrigued by the Fibonacci number sequence, i.e. the sequence where each number is the sum of the two previous.