ChinaUnix.net
相关文章推荐:

linux double 精度

double在处理的时候确实不能保证精度,现在我有程序要写文件。用的是%.2lf的格式。能不能保证正确的四舍五入呢。 [code] bash-2.05$ cat test.c #include int main(void) { double number_a = 11.145; double number_b = 11.445; printf("Number a = %.2lf \n",number_a); printf("Number b = %.2lf \n",number_b); return 0; } bash-2.05$ gcc -o test test.c bash-2.05$ ....

by bigapple2008 - C/C++ - 2007-01-25 16:01:55 阅读(1745) 回复(0)

相关讨论

现在做应用的过程中涉及到利息,可能需要用到小数点后六位。 但是发现,好像double 型的有效数字只有17位,超过的话会将小数点后的数字不正确? 请问如果数值范围超过double 的使用范围应该采用什么样的办法进行处理? 比如我 12345678901.123456 这样的超过了double 型的使用范围。碰到类似的应该如何进行计算呢? 谢谢!

by Advanceer - C/C++ - 2009-07-18 14:58:17 阅读(2882) 回复(10)

我发现大致当double超过340亿时,小数点的精度损失比较明显。比如: double dblx=74000000000.09; fprintf(stderr,"[%lf]\n",dblx); cout.setf(std::ios::fixed); cout.precision(6); cout << dblx << endl; 无论哪种格式,打印出的都是74000000000.089996 若改成34000000000.09出来的就是.090000 照理好像不是double溢出,但假若我是用它表示金额,只有两位小数,这样的问题要怎么解决呢?(之前曾利用round,pow写过这样的函数,但...

by jchc - C/C++ - 2009-04-14 17:33:11 阅读(5474) 回复(8)

编一个程序计算球形的体积。 要求 根据输入球形的半径 输出球形的体积 import java.io.*; public class BallBulk { public static void main(String args[]) { double r=0; System.out.println("Enter a ball radius!"); try{ r=(double)System.in.read(); //接受球形半径 }catch(IOException e){}; Ball e=new Ball(r); //初始一个球型的对象 e.countBulk(); ...

by shining3g - Java - 2006-07-20 00:03:21 阅读(4024) 回复(5)

double d=1.33333333333; java.math.BigDecimal bigDec=new java.math.BigDecimal( bigDec ) ; double d_rtn=bD.setScale(2,java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); System.out.println(d_rtn); 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/7257/showart_93511.html

by hellin - Java文档中心 - 2006-03-31 18:30:44 阅读(1595) 回复(0)

:em02: 是哪个系统调用? 跟windows比哪个更好? 我是菜鸟,谢谢。

by yanghehe - Linux论坛 - 2004-10-13 11:25:38 阅读(1160) 回复(4)

db2 =>; describe table zbgrfhz Column Type Type name schema name Length Scale Nulls ------------------------------ --------- ------------------ -------- ----- ------ ZH SYSIBM CHARACTER 12 0 No HM SYSIBM CHARACTER 8 0 No JGM...

by wzhfs - DB2 - 2005-08-16 01:33:05 阅读(1081) 回复(0)

现在开发的环境下(solaris),double和long double 定义的两个变量里 付值152255285387.1892 printf("[%f]\n", double 变量); printf("[%Lf]\n", long double 变量); printf显示结果都是152255285387.188995 sizeof(double) = 8 sizeof(long double) = 16 谁有这方面的经验吗?

by palmlearn - C/C++ - 2003-04-21 19:16:47 阅读(1300) 回复(3)

double section 一直用的最多的就是section单层循环,实现也比较容易: {{section name=a1 loop=$rows}} {{$rows[a1].name}} {{/section}} 对应的php数组形式: 'xue'); $rows[]=array('name'=>li); /* Array ( [0] => Array ( [name] => xue ) [1] => Array ( [name] => li ) ) */ ?> 倾向使用section,因为她可以直接用mysql返回的数组。记住...

by mosquito_2006 - php文档中心 - 2007-04-12 14:30:49 阅读(660) 回复(0)

流体计算 double型大数组 编译没有问题,但运行出现 segamentation fault 错误! redhat 9 ICC 9 或 gcc 3.2 经多次试验: 数组 在 5000 时 没有问题。 数组 在 50000及以上时 出现上述问题。 有谁有 这样类似的问题嘛?

by 萍水e相逢 - C/C++ - 2008-09-12 16:26:27 阅读(4465) 回复(10)

#include #include #include #include #include main() { char tmp[20]; double d; memset(tmp, 0, sizeof(tmp)); memcpy(tmp, "99999999999999999", sizeof("99999999999999999")); printf("tmp = %s\n", tmp); d = atof(tmp); printf("d = %lf\n", d); printf("errno = %d\n", errno); } 输出 tmp = 99999999999999999 d = 1000000000000...

by pingping09 - C/C++ - 2009-04-06 00:55:23 阅读(3345) 回复(18)