IntFromStr
IntFromStr
Description
Parse a decimal string into an integer. An optional leading + is accepted.
Parameters
| Name | Direction | Description |
|---|---|---|
decimal |
in | Decimal digit string |
Usage example (from documentation)
Int value = IntFromStr("18446744073709551616");Returns
Parsed integer value.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Float.c:330:
}
result.significand = IntFromStr(digits.data);
result.negative = negative && !IntIsZero(&result.significand);
result.exponent = float_sub_i64_checked(explicit_exp, fractional);- In
Int.c:481:
}
Int IntFromStr(const char *decimal) {
if (!decimal) {
LOG_FATAL("decimal is NULL");
const char *digits = "123456789012345678901234567890";
Int value = IntFromStr(digits);
Str text = IntToStr(&value);
bool test_int_from_decimal_invalid_digit(void) {
WriteFmt("Testing IntFromStr invalid digit handling\n");
IntFromStr("12x3"); WriteFmt("Testing IntFromStr invalid digit handling\n");
IntFromStr("12x3");
return false;
}
bool test_int_from_decimal_null(void) {
WriteFmt("Testing IntFromStr NULL handling\n");
IntFromStr(NULL); WriteFmt("Testing IntFromStr NULL handling\n");
IntFromStr(NULL);
return false;
}- In
Io.Write.c:625:
bool success = true;
Int big_dec = IntFromStr("123456789012345678901234567890");
Int hex_val = IntFromHexStr("deadbeefcafebabe1234");
Int bin_val = IntFromBinary("10100011"); WriteFmt("Testing FloatFrom with Int container\n");
Int integer = IntFromStr("12345678901234567890");
Float value = FloatFrom(&integer);
Str text = FloatToStr(&value);- In
Int.Math.c:116:
Int rhs = IntFrom(2);
Int result_value = IntInit();
Int huge = IntFromStr("123456789012345678901234567890");
Str text = StrInit();- In
Int.Math.c:163:
Int result_value = IntInit();
Int preserved = IntFrom(99);
Int huge = IntFromStr("12345678901234567890");
Str text = StrInit();- In
Int.Math.c:227:
WriteFmt("Testing IntMul generic dispatch\n");
Int value = IntFromStr("12345678901234567890");
Int result_value = IntInit();
Str text = StrInit();- In
Int.Math.c:302:
WriteFmt("Testing IntDivMod generic dispatch\n");
Int dividend = IntFromStr("12345678901234567890");
Int quotient = IntInit();
Int remainder = IntInit();- In
Int.Math.c:338:
WriteFmt("Testing IntDivExact generic dispatch\n");
Int dividend = IntFromStr("12345678901234567890");
Int result_value = IntInit();
Str text = StrInit();- In
Int.Math.c:371:
WriteFmt("Testing IntDivMod scalar-divisor dispatch\n");
Int dividend = IntFromStr("12345678901234567890");
Int quotient = IntInit();
Int remainder = IntInit();- In
Int.Math.c:407:
WriteFmt("Testing IntMod scalar-divisor dispatch\n");
Int value = IntFromStr("12345678901234567890");
Int remainder = IntInit();- In
Int.Math.c:759:
WriteFmt("Testing IntIsProbablePrime\n");
Int prime = IntFromStr("1000000007");
Int composite = IntFrom(561);- In
Int.Math.c:773:
WriteFmt("Testing IntNextPrime\n");
Int value = IntFromStr("1000000000");
Int next = IntInit();
Str text = StrInit();
Last updated on