从long long转换为int和另一种方式回到c ++ [英] convert from long long to int and the other way back in c++

查看:562
本文介绍了从long long转换为int和另一种方式回到c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从long long转换为int,另一种方式回到c ++?
还有什么是long long的属性,特别是它的最大尺寸,
谢谢提前..

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 ..

推荐答案

p> type long long通常为64位。

Type long long is typically 64 bits.

类型int可能是32位,但不是所有机器。

Type int is likely to be 32 bits, but not on all machines.

如果你把一个int转换为一个long long,你可以做

If you cast an int to a long long, you can do

my_long_long = (long long) my_int

,它会很好。如果你走另一个方向,如

and it will be just fine. If you go the other direction, like

my_int = (int) my_long_long

且int小于64位,它将无法保存所有信息,因此结果可能不正确。

and the int is smaller than 64-bits, it won't be able to hold all the information, so the result may not be correct.

这篇关于从long long转换为int和另一种方式回到c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆