2019年3月13日

pow()函数结果强制转化为int造成误差的分析

摘要: 开发环境:codeblocks,编译器gcc 在计算102时调用pow(10, 2),再强制类型转换为int类型后输出: 得到的结果却是:99 这是因为 double pow(double x, double y) ,返回值是采用数值逼近的方法得到的double类型值。例如返回值为99.999999 阅读全文

posted @ 2019-03-13 11:38 zkfopen 阅读(1114) 评论(0) 推荐(0) 编辑

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

摘要: 在C++中, 会跳出警告:warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 改成下面会通过warning 或者改成下面: 原因解析: 我们在学习c或者c++的时候都知道,如果在赋值操作 阅读全文

posted @ 2019-03-13 11:01 zkfopen 阅读(23776) 评论(1) 推荐(2) 编辑

导航