Boost logo

Boost :

From: Søren Lassen (s.lassen_at_[hidden])
Date: 2005-04-06 11:47:25


Just a couple of words to introduce myself: I am from Denmark, but
currently living in Nicaragua, where my wife is employed at the Danish
embassy. I suppose this means that my current job title is "spouse".
Before moving, I made a living as a Data Warehouse programmer/analyst.
Having more time on my hands, I decided to spend some of it learning C++.
In my experience, one of the best ways to learn a programming language is
by looking at (and possibly trying to improve) existing code, preferably
of good quality. Which is why I am now showing up on the boost mailing

I have spent some time playing around with the rational.hpp file, and have
made some improvements. Most important is probably operator<, where my new
version is completely safe from overflow and (I think) considerably
faster. Other features are: a member template for converting between
different types of rationals, functions inverse() and power().

Should I put my version of rational.hpp on the sandbox CVS, or mail it to
somebody - or is it not relevant at this time?

Anyway, considering the call for new features: Maybe the class should have
a representation of +-infinity and NAN (the latter follows logically from
the former, because infinity*0->NAN). There may be quite a lot of cases
where it is not the best solution to throw exceptions for divisions by
zero, e.g. a spreadsheet or calculator application, where the user may do
all kinds of funny things - when a division by zero occurs, we just want
to mark the affected variable as infinite, and write "DIV/0" or something
similar in the relevant space in the application UI. The easiest way to
accomplish this is to implement it as a selectable feature in the rational
class, rather than checking for zero before each division, or setting up
try...catch blocks around all the division operations. Of course, the
introduction of NAN rationals makes the class only partially ordered (if
we follow the floating-point standard, where all comparison operations
involving NAN types return false).

P.S. Have I posted this reply to the call for features in the right way?  
If not, what is the right way, using Opera for newsgroups and mail?

Boost list run by bdawes at, gregod at, cpdaniel at, john at