Archives for programming

C++ Templates and Usual Arithmetic Conversions

If you add a short int and a char in C++, what is the resulting type? What if you subtract a long int from an unsigned int? The answers actually depend on the compiler and the target architecture (int or unsigned in the first case and long int or unsigned long int in the second). [...]

Release: Sputsoft Numbers 0.2 (formerly SputArithmetic)

I am very excited about this release. The library has been redesigned and almost everything has been rewritten. Even the name has changed, it is now called Sputsoft Numbers (instead of SputArithmetic).

Continued Fractions and Continuants

We will be considering continued fractions of the form

a_0 + \displaystyle\frac{1}{a_1 + \displaystyle\frac{1}{\ddots + \displaystyle\frac{1}{a_{n-1} + \displaystyle\frac{1}{a_n}}}}

where the a_k‘s are real numbers called the partial quotients [...]

Computing the Greatest Common Divisor

The greatest common divisor of two integers is the largest positive integer that divides them both. This article considers two algorithms for computing gcd(u,v), the greatest common divisor of u and v [...]

Release: SputArithmetic 0.1

This is the first release of the SputArithmetic library. You can download the library or read about it.

Implementing Multiple-Precision Arithmetic, Part 2

Introduction This article is a follow-up to part 1 where multiple-precision addition, subtraction, and multiplication for non-negative integers was discussed. This article deals with division. Again, the theoretic foundation is based on Section 4.3.1, The Classical Algorithms, of The Art of Computer Programming, Volume 2, by Donald E. Knuth.

Implementing Multiple-Precision Arithmetic, Part 1

This article is the first in a series dealing with algorithms for multiple-precision arithmetic. The goal is to present both a theoretical foundation with high-level algorithm descriptions (based on Section 4.3.1, The Classical Algorithms, of The Art of Computer Programming, Volume 2, by Donald E. Knuth) and a portable C++ implementation of the algorithms. The theory and high-level algorithms will be quite universal and generic, whereas the presented code will be just one way to implement the algorithms in a specific programming language.