在控制台程序中定义:

float x;

x=22.333;

编译会出现 warning C4305: “初始化”: 从“double”到“float”截断

系统默认此浮点数是22.333是double型,对float型变量赋值,所以会出现警告。

解决:

1、就将其后面加上f,如2.3f,就告诉系统这是浮点数。

2、由于float是6位有效数字,double是15位。如果有精度要求高的,就将其定义为double,但是占内存从4字节增加到8字节。

zz来源:http://blog.csdn.net/cgcoder/article/details/7367965【shenlan282博客】

warning C4305: “=”: 从“int”到“unsigned char”截断解决方法[zz]的更多相关文章

  1. warning C4305:“初始化”:从“double”到“float”截断

    编译VS项目时出现警告: warning C4305:“初始化”:从“double”到“float”截断(warning C4305: 'initializing' : truncation from ...

  2. error C2220: warning treated as error - no 'object' file generated解决方法

    error C2220: warning treated as error - no 'object' file generated 警讯视为错误 - 生成的对象文件 / WX告诉编译器将所有警告视为 ...

  3. warning: a non-numeric value encountered in line *的解决方法

    今天ytkah在调试项目的时候出现了一个警告warning: a non-numeric value encountered in line 694,查看php官方文档,上面解释说在使用(+ - * ...

  4. for遍历用例数据时,报错:TypeError: list indices must be integers, not dict,'int' object is not iterable解决方法

    一:报错:TypeError: list indices must be integers, not dict for i in range(0,len(test_data)): suite.addT ...

  5. Xhprof graphviz Warning: proc_open() [function.proc-open]: CreateProcess failed, error code 解决方法

    Xhprof在windows下点击[View Full Callgraph]调用graphviz软件时.警告Warning: proc_open() [function.proc-open]: Cre ...

  6. git出现warning: LF will be replaced by CRLF的解决方法

    今天ytkah用git上传文件的时候出现了warning: LF will be replaced by CRLF的错误,具体信息如下,这是因为跨平台开发下产生的.由于编辑器的不同或者Windows程 ...

  7. Integral Promotions整数提升和符号扩展(char,unsigned char,signed char)

    以下来自msdn: Objects of an integral type can be converted to another wider integral type (that is, a ty ...

  8. Calling a C++ dll with unsigned char* parameters

    unsigned char*  等价 BYTE* 例1: C++: int __stdcall LIVESCAN_GetFPRawData(int nChannel, unsigned char *p ...

  9. C/C++中unsigned char和char的区别

    代码: #include <cstdio> #include <iostream> using namespace std; int main(){ unsigned char ...

随机推荐

  1. 关于ClassLoader的一点小问题

    今天在看某框架的源码的时候,遇到一个使用URLClassLoader加载Servlet类的问题,当自己在eclipse里面做试验的时候,始终无法把Class加载成功.比如: ClassLoader c ...

  2. http接口测试——Jmeter接口测试实例讲解

    摘要: 最近做的项目需要测试很多接口,上网查一查,发现完整讲述接口测试的资料太少,所以最近自己做完这个项目,把测试的东西整理一下和大家分享一下,希望对看到的人有所帮助     一.测试需求描述 1. ...

  3. string类find函数返回值判定

     string类find函数返回值判定 代码示例 #include<iostream> #include<cstring> using namespace std; int m ...

  4. 浙江理工2015.12校赛-A

    孙壕请一盘青岛大虾呗 Time Limit: 5 Sec Memory Limit: 128 MB Submit: 577 Solved: 244 Description 话说那一年zstu与gdut ...

  5. vs2015手动安装xamarin

    1.安装jdk Download the Java JDK v1.7.0 installer to any directory on your disk, double-click the downl ...

  6. 如何使用Python调用AutoIt来实现Flash控件的上传功能

    先看一段代码 upload.au3(这个后缀autoit3的格式): ;等待出现title为数据采集-军课网-MozillaFirefox的浏览器窗口 WinWait("数据采集 - XX网 ...

  7. EventBus使用详解(二)——EventBus使用进阶

    一.概述 前一篇给大家装简单演示了EventBus的onEventMainThread()函数的接收,其实EventBus还有另外有个不同的函数,他们分别是: 1.onEvent2.onEventMa ...

  8. [问题2014S03] 复旦高等代数II(13级)每周一题(第三教学周)

    [问题2014S03]  设 \(A\in M_n(\mathbb R)\) 是非异阵并且 \(A\) 的 \(n\) 个特征值都是实数. 若 \(A\) 的所有 \(n-1\) 阶主子式之和等于零, ...

  9. 第 十一 天 Flagmeng 和动画

    1.flagment 的使用,生命周期. 传递数据. 2. 基本动画的使用. 3. 对话框的使用. 4.样式和主题.

  10. 当 IDENTITY_INSERT 设置为 OFF 时,不能为表‘XXX’中的标识列插入显式值。

    在创建事务复制时,很多时候不一定使用快照进行初始化,而是使用备份还原初始化.当对有标识列(即identity的自增列)的表进行复制的时候,使用备份还原初始化搭建起来的复制常常就会报错,即:当 IDEN ...