在控制台程序中定义:

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. 一个用php写的人民币数字转人民币大写的函数

      function num2rmb ($num) {     $c1 = "零壹贰叁肆伍陆柒捌玖";     $c2 = "分角元拾佰仟万拾佰仟亿";     ...

  2. a标签样式

    .a{            cursor:pointer;            color: blue;            text-decoration:none;        }

  3. document.compatMode属性和获取鼠标的位置

    document.compatMode属性 document.compatMode用来判断当前浏览器采用的渲染方式. 官方解释: BackCompat:标准兼容模式关闭.CSS1Compat:标准兼容 ...

  4. ContentProvider总结

    一.使用ContentProvider(内容提供者)共享数据 ContentProvider在android中的作用是对外共享数据,也就是说你可以通过ContentProvider把应用中的数据共享给 ...

  5. 151008:javascript不明白的地方

    http://www.cnblogs.com/ahthw/p/4841405.html,在这里面: function compare(num1, num2){ return num1 - num2; ...

  6. sql索引实例

    1.创建表并插入数据 在Sql Server2008中创建测试数据库Test,接着创建数据库表并插入数据,sql代码如下: USE Test IF EXISTS (SELECT * FROM INFO ...

  7. manacher浅析

    manacher算法的输入是一个字符串,可以计算出以每个字符为中心的最长回文子串的半径.为了避免讨论奇数偶数,将原串的每两个字母之间以及前后各加一个特殊字母,比如'#',那么对于abcbb就变成了 # ...

  8. 使用nodewebx进行前后端开发环境分离

    下载nodewebx(windows环境) npm install nodewebx npm install inherits 为什么要下载inherits,因为nodewebx依赖它... 构建目录 ...

  9. 【OOAD】设计模式概述

    模式的诞生与定义 模式起源于建筑业而非软件业模式(Pattern)之父——美国加利佛尼亚大学环境结构中心研究所所长Christopher Alexander博士<A Pattern Langua ...

  10. 基础笔记3(一)(String StringBuilder StringBuffer 数组)

    ---恢复内容开始--- 1数组.有序的同类型的集合. 2.string :字符串类型:其实就是一个字符数组.添加了private final,所以string是一个不可以变的字符串. String. ...