SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Base class for the family of Rogue Wave decimal classes. More...

#include <rw/tools/decbase.h>

Inheritance diagram for RWDecimalBase:
RWDecimal< M > RWDecimalPortable RWFixedDecimal< M >

Public Types

enum  Op {
  assign , add , sub , mult ,
  div , powop , pow10op , conversion
}
 
enum  RoundingMethod {
  PLAIN , UP , DOWN , BANKERS ,
  TRUNCATE
}
 
enum  State {
  normal , nullstate , NaNstate , ctorError ,
  missingstate , SNaNstate , infinitystate
}
 

Public Member Functions

void swap (RWDecimalBase &rhs)
 

Detailed Description

The base class for the different RWDecimal classes. This class provides the definition of enums used in the derived classes and in the related classes RWDecimalInexactErr and RWDecimalOverflowErr.

Member Enumeration Documentation

◆ Op

An enumeration defining the operation that caused the error handler to be called.

See also
RWDecimalInexactErr and RWDecimalOverflowErr.
Enumerator
assign 

 

add 

 

sub 

 

mult 

 

div 

 

powop 

 

pow10op 

 

conversion 

 

◆ RoundingMethod

Rounding methods used by RWDecimalPortable::round()

The following table shows the results of the different rounding methods.

Method 1.25 1.35 1.251
PLAIN 1.3 1.4 1.3
UP 1.3 1.4 1.3
DOWN 1.2 1.3 1.2
TRUNCATE 1.2 1.3 1.2
BANKERS 1.2 1.4 1.3
Enumerator
PLAIN 

Round up on a tie.

UP 

Always round up.

DOWN 

Always round down.

BANKERS 

On a tie, round so that last digit is even.

TRUNCATE 

Same as DOWN.

◆ State

An enumeration defining the state of the object.

Operations on these enum values apply the following rules from top to bottom (as the operation is evaluated, the first rule that matches is applied).

Operand Operation Behavior Examples
nullstate Any If either operand is nullstate, the other operand is returned. nullstate + n == n
missingstate − nullstate == missingstate
missingstate Any If either operand is missingstate, missingstate is returned. missingstate × n == missingstate
ctorError ÷ missingstate == missingstate
ctorError Any If either operand is ctorError, ctorError is returned. ctorError − n == ctorError
NaNstate × ctorError == ctorError
NaNstate | SNaNstate Any If either operand is NaNstate or SNaNstate, NaNstate is returned. NaNstate + n == NaNstate
infinitystate − SNaNstate == NaNstate
infinitystate Addition If either operand to + is infinitystate, infinitystate is returned. infinitystate + n == infinitystate
n + infinitystate == infinitystate
Subtraction If both operands to − are infinitystate, NaNstate is returned. infinitystate − infinitystate == NaNstate
If the first operand to − is infinitystate, infinitystate is returned. infinitystate − n == infinitystate
If the second operand to − is infinitystate, −infinitystate is returned. n − infinitystate == −infinitystate
Multiplication If either operand to × is infinitystate and the other operand is 0, NaNstate is returned. infinitystate × 0 == NaNstate
0 × −infinitystate == NaNstate
If either operand to × is infinitystate, infinitystate is returned, and sign is propagated according to normal multiplication rules. infinitystate × −n == −infinitystate
−infinitystate × −infinitystate == infinitystate
Division If both operands to ÷ are infinitystate, NaNstate is returned. infinitystate ÷ infinitystate == NaNstate
If the first operand to ÷ is infinitystate, infinitystate is returned,and sign is propagated according to normal division rules. −infinitystate ÷ 0 == −infinitystate
−infinitystate ÷ −n == infinitystate
If the second operand to ÷ is infinitystate, 0 is returned. n ÷ infinitystate == 0
Note
An operation on an object with SNaNstate does not generate signals, unless converted to a double or long double and used in double arithmetic.
Enumerator
normal 

Normal numeric value.

nullstate 

Non-numeric value.

NaNstate 

Quiet NaN.

ctorError 

Error in construction.

missingstate 

Non-numeric value.

SNaNstate 

Signaling NaN.

infinitystate 

Infinity.

Member Function Documentation

◆ swap()

void RWDecimalBase::swap ( RWDecimalBase & rhs)
inline

Swaps the data owned by self with the data owned by rhs.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.