DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
No more ctime(S) errors - Time(C++)

Fixed point arithmetic operators

The fixed point arithmetic operations permit (1) two Durations to be added or subtracted, and (2) a Duration to be multiplied by an integer. These operations yield exact results because Durations are represented internally as fixed point values. Fixed point computation is essential when an action must be performed at precise intervals. For example:

       Duration start = Duration(0);
       Duration end   = Duration::days(100) +
                        Duration::seconds(100);
       Duration delta = Duration::days(1) +
                        Duration::seconds(1);
       for(Duration d = start; d < end; d += delta){
           ...
       }

will execute exactly 100 times at precise intervals of 86401 second, with no drift occurring due to roundoff.

Two fixed point operations affect the sign of a Duration (but not its magnitude): abs() and unary minus.


Next topic: Approximate arithmetic operators
Previous topic: Relational operators

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005