Rounding Class Reference

#include <ql/Math/rounding.hpp>

Inheritance diagram for Rounding:

Inheritance graph
[legend]
List of all members.

Detailed Description

basic rounding class

Tests:
the correctness of the returned values is tested by checking them against known good results.


Public Types

enum  Type {
  None, Up, Down, Closest,
  Floor, Ceiling
}
 rounding methods More...


Public Member Functions

 Rounding (Integer precision, Type type=Closest, Integer digit=5)
Decimal operator() (Decimal value) const


Member Enumeration Documentation

enum Type
 

rounding methods

The rounding methods follow the OMG specification available at ftp://ftp.omg.org/pub/docs/formal/00-06-29.pdf

Warning:
the names of the Floor and Ceiling methods might be misleading
Enumeration values:
None  do not round: return the number unmodified
Up  the first decimal place past the precision will be rounded up. This differs from the OMG rule which rounds up only if the decimal to be rounded is greater than the rounding digit
Down  all decimal places past the precision will be truncated
Closest  the first decimal place past the precision will be rounded up if greater than the rounding digit; this corresponds to the OMG round-up rule. When the rounding digit is 5, the result will be the one closest to the original number, hence the name.
Floor  positive numbers will be rounded up and negative numbers will be rounded down using the OMG round up and round down rules
Ceiling  positive numbers will be rounded down and negative numbers will be rounded up using the OMG round up and round down rules


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen