#include <libpropeller/libpropeller/mtk3339/numbers.h>
|
static char * | Dec (int number, char result_string[]=NULL) |
|
static char * | ZeroPad (char *resultString, int minDigits, bool countSign=false) |
|
static int | Dec (const char *number, const char terminator='\0') |
|
static char * | Hex (int number, const int num_digits, char result_string[]=NULL) |
|
static char * | Bin (int number, int num_digits, char result_string[]=NULL) |
|
static int | DecDigits (int number) |
|
static int | HexDigits (const int n) |
|
static char * | Reverse (char s[]) |
|
static char * | Dec (int number, char result_string[]=NULL) |
|
static char * | ZeroPad (char *resultString, int minDigits, bool countSign=false) |
|
static int | Dec (const char *number, const char terminator='\0') |
|
static char * | Hex (int number, const int num_digits, char result_string[]=NULL) |
|
static char * | Bin (int number, int num_digits, char result_string[]=NULL) |
|
static int | DecDigits (int number) |
|
static int | HexDigits (const int n) |
|
static char * | Reverse (char s[]) |
|
Convert between numbers and the various string representations.
- Author
- SRLM
Definition at line 13 of file numbers.h.
◆ Bin() [1/2]
static char* libpropeller::Numbers::Bin |
( |
int |
number, |
|
|
int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a binary number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be 32 bit integers. This range is not checked.
- Parameters
-
number | The 32 bit number to convert. |
num_digits | The number of binary digits to print. |
result_string | The address to store the string representation. Defaults to the internal buffer if NULL. |
- Returns
- The starting address of the string pointer.
Definition at line 159 of file numbers.h.
◆ Bin() [2/2]
static char* libpropeller::Numbers::Bin |
( |
int |
number, |
|
|
int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a binary number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be 32 bit integers. This range is not checked.
- Parameters
-
number | The 32 bit number to convert. |
num_digits | The number of binary digits to print. |
result_string | The address to store the string representation. Defaults to the internal buffer if NULL. |
- Returns
- The starting address of the string pointer.
Definition at line 159 of file numbers.h.
◆ Dec() [1/4]
static int libpropeller::Numbers::Dec |
( |
const char * |
number, |
|
|
const char |
terminator = '\0' |
|
) |
| |
|
static |
Converts the string representation of a decimal number to it's value.
- Parameters
-
number | the string representation of a base 10 number. Valid characters are '-' (optional) followed by '0' through '9'. |
terminator | optionally specify a termination character to end the string. |
- Returns
- the 32 bit value of the representation. If any characters are not valid numbers or the terminator, then returns INT_MIN.
Definition at line 97 of file numbers.h.
◆ Dec() [2/4]
static int libpropeller::Numbers::Dec |
( |
const char * |
number, |
|
|
const char |
terminator = '\0' |
|
) |
| |
|
static |
Converts the string representation of a decimal number to it's value.
- Parameters
-
number | the string representation of a base 10 number. Valid characters are '-' (optional) followed by '0' through '9'. |
terminator | optionally specify a termination character to end the string. |
- Returns
- the 32 bit value of the representation. If any characters are not valid numbers or the terminator, then returns INT_MIN.
Definition at line 97 of file numbers.h.
◆ Dec() [3/4]
static char* libpropeller::Numbers::Dec |
( |
int |
number, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a decimal number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be in the range of –2,147,483,648 to 2,147,483,647 (32 bit signed integer). This range is not checked.
Note: Effectively the same as the C atoi.
- Parameters
-
number | The 32 bit 2's complement number to convert. |
result_string | The address to store the string representation. |
- Returns
- The starting address of the null terminated string.
Definition at line 29 of file numbers.h.
◆ Dec() [4/4]
static char* libpropeller::Numbers::Dec |
( |
int |
number, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a decimal number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be in the range of –2,147,483,648 to 2,147,483,647 (32 bit signed integer). This range is not checked.
Note: Effectively the same as the C atoi.
- Parameters
-
number | The 32 bit 2's complement number to convert. |
result_string | The address to store the string representation. |
- Returns
- The starting address of the null terminated string.
Definition at line 29 of file numbers.h.
◆ DecDigits() [1/2]
static int libpropeller::Numbers::DecDigits |
( |
int |
number | ) |
|
|
static |
Calculate the number of digits in the decimal representation of a number.
- Returns
- the number of digits that a call to Dec(int) with n will produce.
Definition at line 180 of file numbers.h.
◆ DecDigits() [2/2]
static int libpropeller::Numbers::DecDigits |
( |
int |
number | ) |
|
|
static |
Calculate the number of digits in the decimal representation of a number.
- Returns
- the number of digits that a call to Dec(int) with n will produce.
Definition at line 180 of file numbers.h.
◆ Hex() [1/2]
static char* libpropeller::Numbers::Hex |
( |
int |
number, |
|
|
const int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a hex number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be 32 bit integers. This range is not checked.
- Parameters
-
number | The 32 bit number to convert. |
num_digits | The number of Hex digits to print. |
result_string | The address to store the string representation. Defaults to the internal buffer if NULL. |
- Returns
- The starting address of the string pointer.
Definition at line 133 of file numbers.h.
◆ Hex() [2/2]
static char* libpropeller::Numbers::Hex |
( |
int |
number, |
|
|
const int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
static |
Converts a hex number to it's string representation.
- Warning
- This function modifies the given string.
-
Converted integers must be 32 bit integers. This range is not checked.
- Parameters
-
number | The 32 bit number to convert. |
num_digits | The number of Hex digits to print. |
result_string | The address to store the string representation. Defaults to the internal buffer if NULL. |
- Returns
- The starting address of the string pointer.
Definition at line 133 of file numbers.h.
◆ HexDigits() [1/2]
static int libpropeller::Numbers::HexDigits |
( |
const int |
n | ) |
|
|
static |
Calculate the number of digits in the hexadecimal representation of a number.
- Returns
- the number of digits that a call to Hex(int, ...) with n will produce if there are no leading 0s (ie, counts all the hex digits from left to right, starting with the first non-zero hex digit).
Definition at line 233 of file numbers.h.
◆ HexDigits() [2/2]
static int libpropeller::Numbers::HexDigits |
( |
const int |
n | ) |
|
|
static |
Calculate the number of digits in the hexadecimal representation of a number.
- Returns
- the number of digits that a call to Hex(int, ...) with n will produce if there are no leading 0s (ie, counts all the hex digits from left to right, starting with the first non-zero hex digit).
Definition at line 233 of file numbers.h.
◆ Reverse() [1/2]
static char* libpropeller::Numbers::Reverse |
( |
char |
s[] | ) |
|
|
static |
Reverse the order of a string's characters, in place.
- Warning
- This function modifies the given string.
- Parameters
-
s | zero terminated string to reverse |
- Returns
- the reversed string starting address
Definition at line 273 of file numbers.h.
◆ Reverse() [2/2]
static char* libpropeller::Numbers::Reverse |
( |
char |
s[] | ) |
|
|
static |
Reverse the order of a string's characters, in place.
- Warning
- This function modifies the given string.
- Parameters
-
s | zero terminated string to reverse |
- Returns
- the reversed string starting address
Definition at line 273 of file numbers.h.
◆ ZeroPad() [1/2]
static char* libpropeller::Numbers::ZeroPad |
( |
char * |
resultString, |
|
|
int |
minDigits, |
|
|
bool |
countSign = false |
|
) |
| |
|
static |
Pad a number string with '0' to achieve the minimum number of digits.
- Parameters
-
resultString | The input string to modify, and the destination of the modifications. Must have enough space for the maximum value. |
minDigits | The minimum number of digits. If the number is less than this it will be zero padded. |
countSign | If true the sign is counted as a digit. |
- Returns
- The resultString.
Definition at line 57 of file numbers.h.
◆ ZeroPad() [2/2]
static char* libpropeller::Numbers::ZeroPad |
( |
char * |
resultString, |
|
|
int |
minDigits, |
|
|
bool |
countSign = false |
|
) |
| |
|
static |
Pad a number string with '0' to achieve the minimum number of digits.
- Parameters
-
resultString | The input string to modify, and the destination of the modifications. Must have enough space for the maximum value. |
minDigits | The minimum number of digits. If the number is less than this it will be zero padded. |
countSign | If true the sign is counted as a digit. |
- Returns
- The resultString.
Definition at line 57 of file numbers.h.
The documentation for this class was generated from the following files: