About Infinite Values

Single Variable

INF = 0x7fffffff

The largest value of 32 bit signed int, which is $2^{32} - 1 = 2147483647 \approx{2.147 \times 10^{9}}$

LLINF = 0x7fffffffffffffff (15 fs)

The largest value of 64 bit signed int, which is $2^{64} - 1 = 9223372036854775807 \approx{9.223 \times 10^{18}}$

memset()

memset() works by bytes. For example, in C++, one int variable takes a room of 4 bytes. So when

int var;
memset(var, 0xab, sizeof(var));

and var == 0xabababab

If it is an array, it works by every byte in every element in the array. It is the same as above.

Common Settings

memset(a, 0x3f, sizeof(a))

Similar to for(int i = 0; i < lim; ++i) a[i] = 0x3f3f3f3f;

memset(a, 0x7f, sizeof(a))

Similar to for(int i = 0; i < lim; ++i) a[i] = 0x7f7f7f7f;

memset(a, 0xff, sizeof(a))

Similar to memset(a, -1, sizeof(a)) or for(int i = 0; i < lim; ++i) a[i] = -1;

memset(a, 0, sizeof(a))

Obiviously.

Like

Leave a Reply

Your Email address will not be published. The required items are marked with *