Boost logo

Boost :

From: Andras Erdei (aerdei_at_[hidden])
Date: 2005-03-29 02:53:30


Ross Boylan wrote:

> I use rational<int> in a scientific application. It's specifying a
> step size, and I wanted to avoid situations where, e.g., someone gave
> a step of 1/3 and didn't get exactly 3 steps from 0 to 1.

am i right, that your usage of rational is equivalent to one of:

int d = 3 ;
for ( int n = 0 ; n <= d ; ++n )
    cout << double( n ) / d ;

or

int s = 3 ;
int d = 17 ;
for ( int n = 0 ; n <= d ; n += s )
    cout << double( n ) / d ;

?

if not, can you send me some simplified code snippet?

tia,
andras


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk