IntToStrRadix
IntToStrRadix
Description
Convert an integer to text in the given radix.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to convert |
radix |
in | Radix to use |
uppercase |
in | Use uppercase alphabetic digits when true |
Usage example (from documentation)
Str text = IntToStrRadix(&value, 16, true);Returns
String containing the formatted digits.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:2641:
temp = IntToStr(value);
} else {
temp = IntToStrRadix(value, radix, (fmt_info->flags & FMT_FLAG_CAPS) != 0);
}- In
Int.c:496:
Str IntToStr(Int *value) {
return IntToStrRadix(value, 10, false);
}- In
Int.c:512:
}
Str IntToStrRadix(Int *value, u8 radix, bool uppercase) {
ValidateInt(value);
int_validate_radix(radix);- In
Int.c:560:
Str IntToBinary(Int *value) {
return IntToStrRadix(value, 2, false);
}- In
Int.c:579:
Str IntToOctStr(Int *value) {
return IntToStrRadix(value, 8, false);
}- In
Int.c:591:
Str IntToHexStr(Int *value) {
return IntToStrRadix(value, 16, false);
}
Int value = IntFromStrRadix("zz", 36);
Str text = IntToStrRadix(&value, 36, false);
bool result = IntToU64(&value) == 1295;
Int value = IntFrom(0xBEEF);
Str text = IntToStrRadix(&value, 16, true);
bool result = strcmp(text.data, "BEEF") == 0;
bool test_int_to_str_radix_invalid_radix(void) {
WriteFmt("Testing IntToStrRadix invalid radix handling\n");
Int value = IntFrom(255); Int value = IntFrom(255);
IntToStrRadix(&value, 37, false);
return false;
}
Last updated on