zoukankan      html  css  js  c++  java
  • C++ 强转注意问题

    // test.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    typedef union tagGameAttributeValue
    {
    	int				nValue;
    	unsigned int	uValue;
    	float			fValue;
    	bool            bValue;
    	struct 
    	{
    		short wLo;
    		short wHi;
    	};
    	struct 
    	{
    		unsigned short uwLo;
    		unsigned short uwHi;
    	};
    	struct  
    	{
    		char cLoLo;
    		char cLoHi;
    		char cHiLo;
    		char cHiHi;
    	};
    	struct  
    	{
    		char btLoLo;
    		char btLoHi;
    		char btHiLo;
    		char btHiHi;
    	};
    
    	struct 
    	{
    		unsigned short     wValueLo;
    		struct
    		{
    			unsigned char btValueHiLo;
    			unsigned char btValueHiHi;
    		};
    	};
    }GAMEATTRVALUE, *PGAMEATTRVALUE;
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	GAMEATTRVALUE	value;		//属性值
    	value.nValue = 7;
    	float percentage = (float)5/10;				//percentage = 0.5
    	//float percentage = (float)(5/10);			//percentage = 0
    	value.nValue = value.nValue * percentage;
    	printf("%d
    ",value.nValue);
    	system("pause");
    	return 0;
    }
    
    

  • 相关阅读:
    个人附加作业
    个人最终总结
    结对作业--电梯调度
    VS2015安装&简单的C#单元测试
    C#程序代码分析(第三周)
    HTML学习有感
    gitlab使用有感之坚持
    学习有感

    Activity总结
  • 原文地址:https://www.cnblogs.com/byfei/p/6389676.html
Copyright © 2011-2022 走看看