Newbye quetion:为什么双人可以存储更多的数字而不是长? [英] Newbye quetion: Why a double can store more number than a long ?
问题描述
我的操作系统是:
cronos:jdiaz:tmp> uname -a
HP-UX cronos B.11.11 U 9000/800 820960681无限用户许可证
我在64位模式下编译以下程序:
cronos:jdiaz :tmp> cat kk.C
#include< iostream.h>
#include< limits>
int main()
{
long l_min = numeric_limits< long> :: min();
long l_max = numeric_limits< long> :: max();
double d_min = numeric_limits< double> :: min();
double d_max = numeric_limits< double> :: max();
cout<< sizeof(长)<< " " << sizeof(double)<< endl;
cout<< l_min<< " " << l_max<< " " << d_min<< " " << d_max<<
endl;
返回0;
}
cronos:jdiaz:tmp> a .out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e + 308
双和长类型有相同的大小,但双重限制
更大。任何人都能告诉我这个吗?
谢谢,
何塞路易斯。
Hi,
My OS is:
cronos:jdiaz:tmp>uname -a
HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license
I compile in 64-bits mode the program below:
cronos:jdiaz:tmp>cat kk.C
#include <iostream.h>
#include <limits>
int main()
{
long l_min = numeric_limits<long>::min();
long l_max = numeric_limits<long>::max();
double d_min = numeric_limits<double>::min();
double d_max = numeric_limits<double>::max();
cout << sizeof(long) << " " << sizeof(double) << endl;
cout << l_min << " " << l_max << " " << d_min << " " << d_max <<
endl;
return 0;
}
cronos:jdiaz:tmp>a.out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e+308
The double and long types have the same size, but the double limits
are bigger. Can anyone explein this to me ?
Thanks,
Jose Luis.
推荐答案
-----开始PGP签名消息-----
哈希:SHA1
jose luis fernandez diaz写道:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jose luis fernandez diaz wrote:
我的操作系统是:
cronos:jdiaz:tmp> uname -a
HP-UX cronos B.11.11 U 9000/800 820960681无限用户许可证
我在64位模式下编译下面的程序:
cronos:jdiaz:tmp> cat kk.C
#include< iostream.h>
#include< limits>
{/ l}长l_min = numeric_limits< long> :: min();
long l_max = numeric_limits< long> :: max();
Hi,
My OS is:
cronos:jdiaz:tmp>uname -a
HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license
I compile in 64-bits mode the program below:
cronos:jdiaz:tmp>cat kk.C
#include <iostream.h>
#include <limits>
int main()
{
long l_min = numeric_limits<long>::min();
long l_max = numeric_limits<long>::max();
[snip]
嗯,因为你使用的是另一种来自C的语言,我们在comp.lang.c
新闻组中无法为您提供帮助。你的问题与C无关,应该是
(大概来自交叉发布,是)在与你编写你的例子的
语言相关的论坛中被问到的。这似乎是C ++,所以论坛
将是comp.lang.c ++。
- -
Lew Pitcher
IT顾问,企业应用架构,
企业技术解决方案,道明银行金融集团
(表达的意见是我自己的,不是我的雇主' ')
----- BEGIN PGP SIGNATURE -----
版本:GnuPG v1.2.4(MingW32)
iD8DBQFAljf6agVFX4UWr64RAnujAJwJ4mOsZZ9THxxul4vwzr vTo / acYwCcDLiJ
+ EqfYBtEqbJjlf / u1b7p2DQ =
= 7HZL
----- END PGP SIGNATURE -----
[snip]
Well, since you are using a different language from C, we in the comp.lang.c
newsgroup cannot assist you. Your question does not relate to C, and should be
(presumably, from the crossposting, was) asked in a forum related to the
language in which you wrote your example. This appears to be C++, so that forum
would be comp.lang.c++.
- --
Lew Pitcher
IT Consultant, Enterprise Application Architecture,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers'')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFAljf6agVFX4UWr64RAnujAJwJ4mOsZZ9THxxul4vwzr vTo/acYwCcDLiJ
+EqfYBtEqbJjlf/u1b7p2DQ=
=7HZL
-----END PGP SIGNATURE-----
jose luis fernandez diaz写道:
jose luis fernandez diaz wrote:
我的操作系统是:
cronos:jdiaz:tmp> uname -a
HP-UX cronos B.11.11 U 9000/800 820960681无限用户许可证
我在64位模式下编译程序如下:
cronos:jdiaz:tmp> cat kk.C
#include< iostream.h>
#include< limits>
> int m ain()
{l / l长l_min = numeric_limits< long> :: min();
long l_max = numeric_limits< long> :: max();
double d_min = numeric_limits< ; double> :: min();
double d_max = numeric_limits< double> :: max();
cout<< sizeof(长)<< " " << sizeof(double)<< endl;
cout<< l_min<< " " << l_max<< " " << d_min<< " " << d_max<<
endl;
返回0;
}
cronos:jdiaz:tmp> a.out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e + 308
双和长型具有相同的尺寸,但双重限制
更大。有人可以把这个发给我吗?
Hi,
My OS is:
cronos:jdiaz:tmp>uname -a
HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license
I compile in 64-bits mode the program below:
cronos:jdiaz:tmp>cat kk.C
#include <iostream.h>
#include <limits>
int main()
{
long l_min = numeric_limits<long>::min();
long l_max = numeric_limits<long>::max();
double d_min = numeric_limits<double>::min();
double d_max = numeric_limits<double>::max();
cout << sizeof(long) << " " << sizeof(double) << endl;
cout << l_min << " " << l_max << " " << d_min << " " << d_max <<
endl;
return 0;
}
cronos:jdiaz:tmp>a.out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e+308
The double and long types have the same size, but the double limits
are bigger. Can anyone explein this to me ?
好吧。
1.79769E308
并不意味着该数字精确到最后一位数。这意味着
1797690000000000000000 .... 000000 ..... 000000
和下一个最小的数字可能类似
1797680000000000000000 .... 000000 ..... 000000
因此数字之间存在较大差距。当数字变小时,这些差距会变小。
-
Karl Heinz Buchegger
kb ****** @ gascad.at
jose luis fernandez diaz写道:
jose luis fernandez diaz wrote:
我的操作系统是:
cronos:jdiaz:tmp> uname -a
HP-UX cronos B.11.11 U 9000/800 820960681无限用户许可证
我在64位模式下编译以下程序:
cronos:jdiaz:tmp> cat kk.C
#include< iostream.h>
#include< iostream> //没有.h扩展。
#include< limits>
{
using namespace std;
long l_min = numeric_limits< long> :: min();
long l_max = numeric_limits< long> :: max();
double d_min = numeric_limits< double> :: min();
double d_max = numeric_limits< double> :: max();
cout<< sizeof(长)<< " " << sizeof(double)<< endl;
cout<< l_min<< " " << l_max<< " " << d_min<< " " << d_max<<
endl;
返回0;
}
cronos:jdiaz:tmp> a.out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e + 308
双和长型具有相同的尺寸,但双重限制
更大。任何人都可以向我发布这个吗?
Hi,
My OS is:
cronos:jdiaz:tmp>uname -a
HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license
I compile in 64-bits mode the program below:
cronos:jdiaz:tmp>cat kk.C
#include <iostream.h>
#include <iostream> // No ".h" extension.
#include <limits>
int main()
{
using namespace std;
long l_min = numeric_limits<long>::min();
long l_max = numeric_limits<long>::max();
double d_min = numeric_limits<double>::min();
double d_max = numeric_limits<double>::max();
cout << sizeof(long) << " " << sizeof(double) << endl;
cout << l_min << " " << l_max << " " << d_min << " " << d_max <<
endl;
return 0;
}
cronos:jdiaz:tmp>a.out
8 8
-9223372036854775808 9223372036854775807 2.22507e-308 1.79769e+308
The double and long types have the same size, but the double limits
are bigger. Can anyone explein this to me ?
通常,代表double的一些位被解释为
指数,其余的为乘数。浮点数学结果会产生近似结果,而任何关于
整数字段的操作在应用于long int时会产生精确的结果(如果我们
折扣{over,under} flow)。
http://en.wikipedia.org/wiki/IEEE_fl...point_standard
这篇关于Newbye quetion:为什么双人可以存储更多的数字而不是长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!