HDK
|
Converts a double or float or half to the shortest accurate decimal possible. More...
#include <UT_Digits.h>
Classes | |
struct | to_chars_result |
Public Types | |
enum | Flags { GENERAL = 0, FIXED = 1, SCIENTIFIC = 2, BINARY = 4, OCTAL = 8, HEX = 12, BASE = 12, E_PLUS = 16, E_2 = 32 } |
Public Member Functions | |
UT_Digits () | |
Initialize to empty string. More... | |
void | reset (fpreal64, Flags flags=GENERAL, int precision=-1) |
Change to a new 64-bit double. More... | |
void | reset (fpreal32, Flags flags=GENERAL, int precision=-1) |
Change to a new 32-bit float. More... | |
void | reset (fpreal16, Flags flags=GENERAL, int precision=-1) |
Change to a 16-bit IEEE "half". More... | |
void | reset (int64, Flags flags=GENERAL, int precision=-1) |
Change to an integer. More... | |
void | reset (int32, Flags flags=GENERAL, int precision=-1) |
Change to an integer. More... | |
void | reset (uint64, Flags flags=GENERAL, int precision=-1) |
Change to an unsigned. More... | |
void | reset (uint32, Flags flags=GENERAL, int precision=-1) |
Change to an unsigned. More... | |
UT_Digits (fpreal64 i, Flags flags=GENERAL, int precision=-1) | |
Constructors that do reset(i) More... | |
UT_Digits (fpreal32 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (fpreal16 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (int64 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (int32 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (uint64 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (uint32 i, Flags flags=GENERAL, int precision=-1) | |
UT_Digits (fpreal64 i, int precision) | |
Constructors that take precision but no flags. More... | |
UT_Digits (fpreal32 i, int precision) | |
UT_Digits (fpreal16 i, int precision) | |
const char * | c_str () const |
Return the formatted string, which is stored in an internal buffer. More... | |
const char * | data () const |
Return the formatted string, which is stored in an internal buffer. More... | |
unsigned | size () const |
Length of the string. More... | |
char | operator[] (unsigned i) const |
get the bytes of the formatted text More... | |
operator const char * () const | |
Return the formatted string, which is stored in an internal buffer. More... | |
operator fpreal64 () const | |
operator bool () const | |
Returns true if reset to a non-zero value. More... | |
bool | operator!= (const char *) const |
String equality, useful for testing. More... | |
bool | operator== (const char *v) const |
void | insert (unsigned i, const char *c, unsigned len) |
void | insert (unsigned i, char c, unsigned len=1) |
void | pad0 (Flags flags, int digits) |
add leading zeros so there are n digits More... | |
void | grouping (Flags flags) |
insert commas every 3 leading digits (or _ every 4 for hex) More... | |
void | prefix (Flags flags) |
add C prefix such as "0x" More... | |
void | plus (bool space=false) |
add a '+' or ' ' to positive numbers More... | |
void | uppercase () |
void | append (char c) |
char * | write (char *start, char *end) const |
Static Public Member Functions | |
static to_chars_result | to_chars (char *start, char *end, fpreal64 v, Flags flags=GENERAL, int precision=-1) |
static to_chars_result | to_chars (char *start, char *end, fpreal32 v, Flags flags=GENERAL, int precision=-1) |
static to_chars_result | to_chars (char *start, char *end, fpreal16 v, Flags flags=GENERAL, int precision=-1) |
static to_chars_result | to_chars (char *start, char *end, int64 v) |
static to_chars_result | to_chars (char *start, char *end, int32 v) |
static to_chars_result | to_chars (char *start, char *end, uint64 v) |
static to_chars_result | to_chars (char *start, char *end, uint32 v) |
static Flags | toFlags (int base) |
static to_chars_result | to_chars (char *start, char *end, int64 v, int base) |
static to_chars_result | to_chars (char *start, char *end, int32 v, int base) |
static to_chars_result | to_chars (char *start, char *end, uint64 v, int base) |
static to_chars_result | to_chars (char *start, char *end, uint32 v, int base) |
Converts a double or float or half to the shortest accurate decimal possible.
Definition at line 22 of file UT_Digits.h.
enum UT_Digits::Flags |
Definition at line 25 of file UT_Digits.h.
|
inline |
Initialize to empty string.
Definition at line 38 of file UT_Digits.h.
Constructors that do reset(i)
Definition at line 55 of file UT_Digits.h.
Definition at line 56 of file UT_Digits.h.
Definition at line 57 of file UT_Digits.h.
Definition at line 58 of file UT_Digits.h.
Definition at line 59 of file UT_Digits.h.
Definition at line 60 of file UT_Digits.h.
Definition at line 61 of file UT_Digits.h.
Constructors that take precision but no flags.
Definition at line 64 of file UT_Digits.h.
Definition at line 65 of file UT_Digits.h.
Definition at line 66 of file UT_Digits.h.
|
inline |
Definition at line 104 of file UT_Digits.h.
|
inline |
Return the formatted string, which is stored in an internal buffer.
Definition at line 69 of file UT_Digits.h.
|
inline |
Return the formatted string, which is stored in an internal buffer.
Definition at line 71 of file UT_Digits.h.
void UT_Digits::insert | ( | unsigned | i, |
const char * | c, | ||
unsigned | len | ||
) |
void UT_Digits::insert | ( | unsigned | i, |
char | c, | ||
unsigned | len = 1 |
||
) |
|
explicit |
Returns true if reset to a non-zero value.
|
inline |
Return the formatted string, which is stored in an internal buffer.
Definition at line 78 of file UT_Digits.h.
|
explicit |
Cast to a double that will format to the same digits. This is useful to convert a float or half to the "expected" double value.
bool UT_Digits::operator!= | ( | const char * | ) | const |
String equality, useful for testing.
|
inline |
Definition at line 94 of file UT_Digits.h.
|
inline |
get the bytes of the formatted text
Definition at line 75 of file UT_Digits.h.
void UT_Digits::plus | ( | bool | space = false | ) |
add a '+' or ' ' to positive numbers
Change to a new 64-bit double.
Change to a new 32-bit float.
Change to a 16-bit IEEE "half".
|
inline |
Length of the string.
Definition at line 73 of file UT_Digits.h.
|
inlinestatic |
Definition at line 114 of file UT_Digits.h.
|
inlinestatic |
Definition at line 116 of file UT_Digits.h.
|
inlinestatic |
Definition at line 118 of file UT_Digits.h.
|
inlinestatic |
Definition at line 121 of file UT_Digits.h.
|
inlinestatic |
Definition at line 123 of file UT_Digits.h.
|
inlinestatic |
Definition at line 125 of file UT_Digits.h.
|
inlinestatic |
Definition at line 127 of file UT_Digits.h.
|
inlinestatic |
Definition at line 131 of file UT_Digits.h.
|
inlinestatic |
Definition at line 133 of file UT_Digits.h.
|
inlinestatic |
Definition at line 135 of file UT_Digits.h.
|
inlinestatic |
Definition at line 137 of file UT_Digits.h.
Definition at line 130 of file UT_Digits.h.
void UT_Digits::uppercase | ( | ) |
char* UT_Digits::write | ( | char * | start, |
char * | end | ||
) | const |