Go to the first, previous, next, last section, table of contents.


CNFormFloat -- Doubles as CNStrings

SYNOPSIS

#include <CNCL/FormFloat.h>

TYPE

CN_FORMFLOAT

BASE CLASSES

CNString

DERIVED CLASSES

None

RELATED CLASSES

CNFormInt

DESCRIPTION

This class converts doubles to CNStrings using different kinds of format styles provided by the stream-2.0-implementation. The current formats implemented in this class are 'left' and 'right' in connection with 'scientific', 'showpoint' or 'fixed'. Note: If the number is too long, the right part of it will be cut, no matter wich format style is chosen. If the number is cut (because of the chosen precision) it will be round. If the precision is not in the interval [0,16] problems with the accuracy might occur.

Constructors:

CNFormFloat();
CNFormFloat(CNParam *param);
CNFormFloat(double x, int w);
CNFormFloat(double x, int w, char fill);
CNFormFloat(double x, int w, char fill, int format);
CNFormFloat(double x, int w, char fill, int format, int pr);
Initializes the FormFloat with the value x (default = 0.0), the width w (= 3), the fill character fill (= ' '), the format (= right) and the precision pr (= 6).

The different formats implemented in CNFormFloat are:

int right = 1
int left = 2
int scientific = 4
int showpoint = 8
int fixed = 16
These formats can be devided into two groups: right and left on one hand and scientific, showpoint and fixed on the other. Those two groups can be combiened with each other, e.g. left and scientific (= 6) is as far possible as right and fixed (= 17).

In addition to the member functions required by CNCL, CNFormFloat provides:

double get_value();
double value();
char get_fill();
char fill();
formats get_format();
formats format();
int get_width();
int width();
int get_precision();
int precision();
Returns value, fill character, format style, width or precision of the current CNFormFloat.
void set_value(double x);
void value(double x);
void set_fill(char f);
void fill(char f);
void set_format(formats f);
format(formats f);
void set_width(int w);
void width(int w);
void set_precision(int pr);
void precision(int pr);
Changes the current CNFormFloat by its value, fill character, format style, width or precision.


Go to the first, previous, next, last section, table of contents.