I want to get the low 32 bit of a int64 as int32

前端 未结 5 1268
梦如初夏
梦如初夏 2021-01-04 05:02

I have an Int64 value, but I only need the lower 32 bits. Thus I want a quick way to get the Int32 value from the lower 32 bits of the Int64 value.

Thanks

5条回答
  •  独厮守ぢ
    2021-01-04 05:29

    You could let the compiler handle the endian-ness, and hide all the bit shifting, pointer manipulation etc.

    DWORD CUtility::ConvertUint64toUint32(unsigned __int64 in64){
        ULARGE_INTEGER uli;
        uli.QuadPart = in64;
        return uli.LowPart;
    }
    

提交回复
热议问题