convert from long long to int and the other way back in c++

前端 未结 3 1604
故里飘歌
故里飘歌 2021-02-01 06:33

How to convert from long long to int and the other way back in c++ ?? also what are the properties of long long , especially its maximum size, thank in advance ..

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 07:07

    Size of int is only 2 bytes whereas the other one is usually larger than int. So if you are looking to convert long into int then you would end up loosing information. But the other way is possible without sacrificing the correctness of information. Suppose a is of long type and b is of int type. Then int to long covertion:a=(long)b; . For other way:b=(int)a;.

提交回复
热议问题