libDwm-0.9.45
Dwm::EngFormat Class Reference

Class to format numbers in an engineering-type form. More...

#include <DwmEngFormat.hh>

Public Member Functions

 EngFormat (const uint64_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const uint32_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const uint16_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const int64_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const int32_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const int16_t &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const float &val, uint8_t precision=4, uint8_t width=5)
 
 EngFormat (const double &val, uint8_t precision=4, uint8_t width=5)
 

Friends

std::ostream & operator<< (std::ostream &os, const EngFormat &ef)
 

Detailed Description

Class to format numbers in an engineering-type form.

Instead of printing numerical powers of 10, we print 'K' (kilo), 'M' (mega), 'm' (milli), 'u' (micro), et. al.

Example:

uint32_t v = 123456; std::cout << Dwm::EngFormat(v) << std::endl;

would print:

123.5K

precision is the maximum precision (places including those to the left of the decimal point) to print. width is the minimum field width to print; we right-justify and fill with spaces.


The documentation for this class was generated from the following file: