Convert between numbers and the various string representations.
More...
#include <numbers.h>
|
| static char * | Dec (int number, char result_string[]=NULL) |
| | Converts a decimal number to it's string representation. More...
|
| |
| static int | Dec (const char *number, const char terminator= '\0') |
| | Converts the string representation of a decimal number to it's value. More...
|
| |
| static char * | Hex (int number, const int num_digits, char result_string[]=NULL) |
| | Converts a hex number to it's string representation. More...
|
| |
| static char * | Bin (int number, int num_digits, char result_string[]=NULL) |
| | Converts a binary number to it's string representation. More...
|
| |
| static int | DecDigits (int number) |
| | Calculate the number of digits in the decimal representation of a number. More...
|
| |
| static int | HexDigits (const int n) |
| | Calculate the number of digits in the hexadecimal representation of a number. More...
|
| |
| static char * | Reverse (char s[]) |
| | Reverse the order of a string's characters, in place. More...
|
| |
Convert between numbers and the various string representations.
- Author
- SRLM
| static char* Numbers::Bin |
( |
int |
number, |
|
|
int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
inlinestatic |
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.
| static char* Numbers::Dec |
( |
int |
number, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
inlinestatic |
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.
| static int Numbers::Dec |
( |
const char * |
number, |
|
|
const char |
terminator = '\0' |
|
) |
| |
|
inlinestatic |
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.
| static int Numbers::DecDigits |
( |
int |
number) | |
|
|
inlinestatic |
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.
| static char* Numbers::Hex |
( |
int |
number, |
|
|
const int |
num_digits, |
|
|
char |
result_string[] = NULL |
|
) |
| |
|
inlinestatic |
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.
| static int Numbers::HexDigits |
( |
const int |
n) | |
|
|
inlinestatic |
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).
| static char* Numbers::Reverse |
( |
char |
s[]) | |
|
|
inlinestatic |
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
The documentation for this class was generated from the following files: