Memset 3 F
There is no fixed way to represent Infinity. The first option that might come to our mind is 0x7f ff ff ff = 2^31 - 1 = 2,147,483,647 which is the maximum value of 32-bit int.
This choice has one issue -- when adding Infinity with another number, you will get overflow error.
A better choice is 0x3f 3f 3f 3f = 1,061,109,567.
It is of the same order of magnitude as
0x7f ff ff ffbut twice of it is still within the range ofint.When using
memsetto initialize an array ofint, sincememsetis filling values asunsigned char,memset(A, 0x3f, sizeof(A))will perfectly fill0x3f 3f 3f 3finto the array.
Reference
Last updated
Was this helpful?