HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_FormatNumber.h File Reference
#include "SYS_API.h"
#include "SYS_Types.h"
+ Include dependency graph for SYS_FormatNumber.h:

Go to the source code of this file.

Enumerations

enum  SYS_FormatFlags {
  SYS_FormatFlags::None = 0x00, SYS_FormatFlags::AddCPrefix = 0x01, SYS_FormatFlags::UpperCase = 0x02, SYS_FormatFlags::AddPlus = 0x04,
  SYS_FormatFlags::DigitGrouping = 0x08
}
 
enum  SYS_FormatNotation {
  SYS_FormatNotation::Shortest, SYS_FormatNotation::Fixed, SYS_FormatNotation::Scientific, SYS_FormatNotation::Hexadecimal,
  SYS_FormatNotation::Engineering
}
 Specifies the notation to use when formatting floating point numbers. More...
 

Functions

SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, int8 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, uint8 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, int16 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, uint16 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, int32 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, uint32 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, int64 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatInteger (char *buffer, size_t buffer_size, uint64 number, int base=10, int min_digits=0, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatFloat (char *buffer, size_t buffer_size, fpreal16 number, uint32 precision=4, SYS_FormatNotation notation=SYS_FormatNotation::Shortest, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatFloat (char *buffer, size_t buffer_size, fpreal32 number, uint32 precision=6, SYS_FormatNotation notation=SYS_FormatNotation::Shortest, SYS_FormatFlags flags=SYS_FormatFlags::None)
 
SYS_API size_t SYSformatFloat (char *buffer, size_t buffer_size, fpreal64 number, uint32 precision=8, SYS_FormatNotation notation=SYS_FormatNotation::Shortest, SYS_FormatFlags flags=SYS_FormatFlags::None)
 

Enumeration Type Documentation

enum SYS_FormatFlags
strong
Enumerator
None 

Just output the raw number in the given base.

AddCPrefix 

Add the C prefixes for the appropriate base. E.g. 0x for hexadecimal (base 16), 0 for octal (base 8) and 0b for binary (base 2, a C++11 extension).

UpperCase 

Alphabetic digits should be printed in upper-case instead of default lower-case.

AddPlus 

Always show a sign to indicate the sign of the number. Usually only the negative sign is shown for negative numbers, but this will add a positive sign for positive numbers too.

DigitGrouping 

Add digit groupings for the integer part of the

Definition at line 18 of file SYS_FormatNumber.h.

enum SYS_FormatNotation
strong

Specifies the notation to use when formatting floating point numbers.

Enumerator
Shortest 

Print using the shortest representation, picking either fixed-point or normalized scientific notation, as needed. Corresponds to printf's 'g'/'G' formatting codes.

Fixed 

Print using fixed-point notation. Corresponds to printf's 'f'/'F' formatting code.

Scientific 

Print using normalized scientific notation. Corresponds to printf's 'e'/'E' formatting code.

Hexadecimal 

Print using the C99 hexadecimal float notation. Corresponds to printf's 'a'/'A' formatting code.

Engineering 

Print using engineering notation. This is similar to normalized scientific notation, except the powers are always divisible by 3.

Definition at line 108 of file SYS_FormatNumber.h.

Function Documentation

SYS_API size_t SYSformatFloat ( char *  buffer,
size_t  buffer_size,
fpreal16  number,
uint32  precision = 4,
SYS_FormatNotation  notation = SYS_FormatNotation::Shortest,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)

Write the text version of float value into a character buffer specified by buffer of size buffer_size. The number of characters written is returned. No string terminator value is written out. If the buffer given is nullptr, then this function immediately returns the amount of space needed to store the string.

SYS_API size_t SYSformatFloat ( char *  buffer,
size_t  buffer_size,
fpreal32  number,
uint32  precision = 6,
SYS_FormatNotation  notation = SYS_FormatNotation::Shortest,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatFloat ( char *  buffer,
size_t  buffer_size,
fpreal64  number,
uint32  precision = 8,
SYS_FormatNotation  notation = SYS_FormatNotation::Shortest,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
int8  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)

Write the text version of an integer value into a character buffer specified by buffer of size buffer_size. The number of characters written is returned. Note that a string terminator value is not written out.

Parameters
bufferThe character buffer to copy the formatted number into. If this value is nullptr, then the value returned will be the number of bytes required to store the result.
buffer_sizeThe size of the buffer given in buffer. If buffer is nullptr, this value is ignored.
numberThe number to convert to a text representation.
baseThe numerical base the number will be converted to.
min_digitsThe minimum number of digits to write out. If this value is greater than the actual number of digits needed, the final value will be zero-padded after the sign charadcter.
flagsThe flags specifying the formatting.
Returns
The number of bytes written out to buffer. If buffer is nullptr, then the size of the buffer required to write out the entire value is returned.
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
uint8  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
int16  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
uint16  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
int32  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
uint32  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
int64  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)
SYS_API size_t SYSformatInteger ( char *  buffer,
size_t  buffer_size,
uint64  number,
int  base = 10,
int  min_digits = 0,
SYS_FormatFlags  flags = SYS_FormatFlags::None 
)