IntToU64
IntToU64
Description
Convert an integer to u64.
Aborts if the integer does not fit in 64 bits.
Parameters
| Name | Direction | Description |
|---|---|---|
value |
in | Integer to convert |
Usage example (from documentation)
u64 small = IntToU64(&value);Returns
The numeric value as u64.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Int.c:369:
}
u64 IntToU64(Int *value) {
ValidateInt(value);- In
Int.c:627:
}
u64 lhs_value = IntToU64(lhs);
if (lhs_value < rhs) {- In
Int.c:884:
}
MISRA_PRIV_IntPowU64(result, base, IntToU64(exponent));
}- In
Int.c:1074:
IntDivMod(quotient, &remainder, dividend, &divisor_value);
rem = IntToU64(&remainder);
IntDeinit(&divisor_value);- In
Int.Convert.c:43:
bool result = IntBitLength(&value) == 4;
result = result && (IntToU64(&value) == 13);
result = result && (strcmp(text.data, "1101") == 0);- In
Int.Convert.c:93:
Str text = IntToBinary(&value);
bool result = IntToU64(&value) == 11;
result = result && (strcmp(text.data, "1011") == 0); Str text = IntToStrRadix(&value, 36, false);
bool result = IntToU64(&value) == 1295;
result = result && (strcmp(text.data, "zz") == 0); bool result = IntBitLength(&zero) == 0;
result = result && IntIsZero(&zero);
result = result && (IntToU64(&zero) == 0);
result = result && (strcmp(text.data, "0") == 0); Int value = IntFromBinary("0b1010_0011");
bool result = IntToU64(&value) == 163;
result = result && (IntBitLength(&value) == 8); Str text = IntToOctStr(&value);
bool result = IntToU64(&value) == 493;
result = result && (strcmp(text.data, "755") == 0);
bool test_int_to_u64_overflow(void) {
WriteFmt("Testing IntToU64 overflow handling\n");
Int value = IntFrom(1); Int value = IntFrom(1);
IntShiftLeft(&value, 64);
IntToU64(&value);
return false;- In
Int.Math.c:68:
IntShiftLeft(&value, 4);
bool result = IntToU64(&value) == 48;
result = result && (IntBitLength(&value) == 6);- In
Int.Math.c:82:
IntShiftRight(&value, 4);
bool result = IntToU64(&value) == 3;
result = result && (IntBitLength(&value) == 2);- In
Int.Math.c:100:
text = IntToBinary(&result_value);
bool result = IntToU64(&result_value) == 256;
result = result && (strcmp(text.data, "100000000") == 0);- In
Int.Math.c:120:
IntAdd(&result_value, &base, rhs);
bool result = IntToU64(&result_value) == 42;
IntAdd(&result_value, &base, 2);- In
Int.Math.c:123:
IntAdd(&result_value, &base, 2);
result = result && (IntToU64(&result_value) == 42);
IntAdd(&result_value, &base, -2);- In
Int.Math.c:126:
IntAdd(&result_value, &base, -2);
result = result && (IntToU64(&result_value) == 38);
IntAdd(&result_value, &huge, 10);- In
Int.Math.c:148:
bool result = IntSub(&result_value, &a, &b);
result = result && (IntToU64(&result_value) == 255);
IntDeinit(&a);- In
Int.Math.c:167:
bool result = IntSub(&result_value, &base, rhs);
result = result && (IntToU64(&result_value) == 38);
result = result && IntSub(&result_value, &base, 2u);- In
Int.Math.c:170:
result = result && IntSub(&result_value, &base, 2u);
result = result && (IntToU64(&result_value) == 38);
result = result && IntSub(&result_value, &base, -2);- In
Int.Math.c:173:
result = result && IntSub(&result_value, &base, -2);
result = result && (IntToU64(&result_value) == 42);
result = result && IntSub(&result_value, &huge, 90);- In
Int.Math.c:180:
result = result && !IntSub(&preserved, &base, 50);
result = result && (IntToU64(&preserved) == 99);
IntDeinit(&base);- In
Int.Math.c:199:
bool result = !IntSub(&result_value, &a, &b);
result = result && (IntToU64(&result_value) == 99);
IntDeinit(&a);- In
Int.Math.c:216:
IntMul(&result_value, &a, &b);
bool result = IntToU64(&result_value) == 126;
IntDeinit(&a);- In
Int.Math.c:252:
bool result = IntIsZero(&result_value);
result = result && (IntToU64(&result_value) == 0);
IntDeinit(&a);- In
Int.Math.c:268:
IntSquare(&result_value, &value);
bool result = IntToU64(&result_value) == 152399025;
IntDeinit(&value);- In
Int.Math.c:311:
bool result = strcmp(qtext.data, "127275040218913071") == 0;
result = result && (IntToU64(&remainder) == 3);
StrDeinit(&qtext);- In
Int.Math.c:328:
IntDiv(&result_value, ÷nd, 10u);
bool result = IntToU64(&result_value) == 12;
IntDeinit(÷nd);- In
Int.Math.c:360:
bool result = !IntDivExact(&result_value, ÷nd, &divisor);
result = result && (IntToU64(&result_value) == 99);
IntDeinit(÷nd);- In
Int.Math.c:380:
bool result = strcmp(text.data, "127275040218913071") == 0;
result = result && (IntToU64(&remainder) == 3);
IntDeinit(÷nd);- In
Int.Math.c:397:
IntMod(&result_value, ÷nd, 10u);
bool result = IntToU64(&result_value) == 6;
IntDeinit(÷nd);- In
Int.Math.c:413:
IntDeinit(&value);
bool result = IntToU64(&remainder) == 3;
IntDeinit(&remainder);
return result;- In
Int.Math.c:427:
IntGCD(&result_value, &a, &b);
bool result = IntToU64(&result_value) == 6;
IntDeinit(&a);- In
Int.Math.c:444:
IntLCM(&result_value, &a, &b);
bool result = IntToU64(&result_value) == 42;
IntDeinit(&a);- In
Int.Math.c:460:
IntRoot(&result_value, &value, 4);
bool result = IntToU64(&result_value) == 8;
IntDeinit(&value);- In
Int.Math.c:476:
IntRootRem(&root, &remainder, &value, 3);
bool result = IntToU64(&root) == 5;
result = result && (IntToU64(&remainder) == 75);- In
Int.Math.c:477:
bool result = IntToU64(&root) == 5;
result = result && (IntToU64(&remainder) == 75);
IntDeinit(&value);- In
Int.Math.c:493:
IntSqrt(&result_value, &value);
bool result = IntToU64(&result_value) == 14;
IntDeinit(&value);- In
Int.Math.c:509:
IntSqrtRem(&root, &remainder, &value);
bool result = IntToU64(&root) == 14;
result = result && (IntToU64(&remainder) == 4);- In
Int.Math.c:510:
bool result = IntToU64(&root) == 14;
result = result && (IntToU64(&remainder) == 4);
IntDeinit(&value);- In
Int.Math.c:576:
IntSquareMod(&result_value, &value, &mod);
bool result = IntToU64(&result_value) == 94;
IntDeinit(&value);- In
Int.Math.c:594:
IntModAdd(&result_value, &a, &b, &m);
bool result = IntToU64(&result_value) == 12;
IntDeinit(&a);- In
Int.Math.c:613:
IntModSub(&result_value, &a, &b, &m);
bool result = IntToU64(&result_value) == 9;
IntDeinit(&a);- In
Int.Math.c:632:
IntModMul(&result_value, &a, &b, &m);
bool result = IntToU64(&result_value) == 22;
IntDeinit(&a);- In
Int.Math.c:651:
bool result = IntModDiv(&result_value, &a, &b, &m);
result = result && (IntToU64(&result_value) == 12);
IntModMul(&check, &result_value, &b, &m);- In
Int.Math.c:673:
IntPowMod(&result_value, &base, 20u, &mod);
bool result = IntToU64(&result_value) == 3;
IntDeinit(&base);- In
Int.Math.c:691:
IntPowMod(&result_value, &base, &exp, &mod);
bool result = IntToU64(&result_value) == 445;
IntDeinit(&base);- In
Int.Math.c:709:
bool result = IntModInv(&result_value, &value, &mod);
result = result && (IntToU64(&result_value) == 4);
IntModMul(&check, &value, &result_value, &mod);- In
Int.Math.c:712:
IntModMul(&check, &value, &result_value, &mod);
result = result && (IntToU64(&check) == 1);
IntDeinit(&value);- In
Int.Math.c:796:
bool result = !IntModInv(&result_value, &value, &mod);
result = result && (IntToU64(&result_value) == 99);
IntDeinit(&value);- In
Int.Type.c:44:
bool result = IntEQ(&clone, &original);
result = result && (IntToU64(&clone) == 11);
IntShiftLeft(&original, 1);- In
Int.Type.c:49:
result = result && !IntEQ(&clone, &original);
result = result && (IntToU64(&clone) == 11);
result = result && (IntToU64(&original) == 22);- In
Int.Type.c:50:
result = result && !IntEQ(&clone, &original);
result = result && (IntToU64(&clone) == 11);
result = result && (IntToU64(&original) == 22);
IntDeinit(&original);
Last updated on