I wrote a custom atoi
function and wanted to write some tests for the types int32_t,uint32_t,int,double
to know it is doing the conversion correct. For the test I'll give it the maximum and min values and see if the conversion is correct.What I would like to know is if the approach I am taking to determining the max and min values of the type are correct.
This is my approach : To confirm the sizes of types I am using this link Now the link states that the size of int_32_t
(which by default is signed) will be 16 bits
in LP32 .So max 16 bit no is 65535
. But since its signed we will get a max of 65535/2 = 32767.5
so I am assuming its range will be -32767 to 32767
? Am I correct ? And similarly for uint32_t
the size is will be 16 bits
in LP32 .So max 16 bit no is 65535
so range will be 0 to 65535
? Am I correct ? Also what is the difference between LP32
and ILP32
which one should I be following ?
Aucun commentaire:
Enregistrer un commentaire