转换__int64长在Windows [英] Converting __int64 to long in Windows
问题描述
如何转换__int64长在Windows(MSVC8&安培; MSVC6)?
How to convert __int64 to long in Windows (MSVC8 & MSVC6)?
将一个正常的类型转换工作?
Will a normal typecasting work?
另外,如何有关转换长时间__int64?如果长为负值,它将工作
Also, how about converting long to __int64? If the long is a negative value, will it work?
注 - 我说,其中__int64变量将总是包含这将不会超过32位长的值的情况下的
Note - I am talking of a scenario in which the __int64 variable will always contain a value which will not be more than 32 bits long.
推荐答案
1。转换长__int64
Acorrding到 MSDN 上的 __int64
关键字:
Acorrding to MSDN on the __int64
keyword:
_该关键字_int64声明新
输入时,64位(8字节)整数。如
与INT,短,长的类型,
该_ _int64类型都有一个相应
未签名版本,所以_ _int64
关键字实际上可以被用来创建
两种类型的
The _ _int64 keyword declares a new type, a 64-bit (8-byte) integer. As with the int, short, and long types, the _ _int64 type has a corresponding unsigned version, so the _ _int64 keyword actually can be used to create two types.
以下code示例显示了如何
声明两个64位整数,一是
符号和其他符号:
The following code sample shows how to declare two 64-bit integers, one signed and the other unsigned:
__的Int64 signed_big_int;无符号__int64 unsigned_big_int;
__int64 signed_big_int; unsigned __int64 unsigned_big_int;
__的Int64
签署,它应该比长更宽
。所以,你可以指定长
到 __的Int64
,甚至没有一个类型转换,当然还有签署__int64
支持负长。
__int64
is signed,and it should be wider than long
.So you could assign long
to __int64
without even a type cast and of course the signed __int64
support negative long.
2。转换__int64长
这是确定 __的Int64
转换为长
,只有失去data.My msvc8只是警告我的可能的数据丢失的pssibility
It is OK to convert __int64
to long
,only with possibility of loosing data.My msvc8 only warn me of the pssibility of loss of data.
3。注意
C99在的int64_t
和未签名版 uint64_t中
> stdint.h 。如果你想提供便携式code,你应该使用他们,但没有 __的Int64
。
C99 defined a standard 64-bit integer type named int64_t
and unsigned version uint64_t
in stdint.h
.If you want to provide portable code, you should use them but not __int64
.
的通知中有C ++编程语言没有标准的64位整数类型,MSVC使用 __的Int64
,但在Linux世界中通常使用的int64_t
或 uint64_t中
其类型定义为长长
或无符号长长
C99中的 stdint.h
。在这里我假设你的C ++编译器支持 stdint.h
头文件。
Notice there is no standard 64-bit integer type in C++ programming language,MSVC use __int64
,but in linux world you normally use int64_t
or uint64_t
which is type defined as long long
or unsigned long long
in C99's stdint.h
.Here I assume your C++ compiler support the stdint.h
header file.
这篇关于转换__int64长在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!