w****n 发帖数: 31 | 1 有谁能在Pentium 的CPU上得到这样的计算结果:
1.0/3.0=0.33333333333333333333 (3的个数多于16位)?
要是谁能写这么一个程序,我就佩服他了。当然是用最简单的办法。 不论什么complior
和platform(Suse, redhat, or XP ...). 但是一定要使Pentium 的CPU. |
t*****e 发帖数: 13 | 2
这是Pentium 4上得结果,正好16个3:
program main
real(8) :: a,b,c
c = 1.d0/3.d0
print'(F20.18)',c
end
0.333333333333333303
【在 w****n 的大作中提到】 : 有谁能在Pentium 的CPU上得到这样的计算结果: : 1.0/3.0=0.33333333333333333333 (3的个数多于16位)? : 要是谁能写这么一个程序,我就佩服他了。当然是用最简单的办法。 不论什么complior : 和platform(Suse, redhat, or XP ...). 但是一定要使Pentium 的CPU.
|
w****n 发帖数: 31 | 3 忘记说了,一定要用C++/C
不论什么complior
【在 t*****e 的大作中提到】 : : 这是Pentium 4上得结果,正好16个3: : program main : real(8) :: a,b,c : c = 1.d0/3.d0 : print'(F20.18)',c : end : 0.333333333333333303
|
i*****w 发帖数: 356 | 4 换UNIX系统。 换REAL8. 好像能更多位吧
【在 w****n 的大作中提到】 : 忘记说了,一定要用C++/C : : 不论什么complior
|
h***o 发帖数: 539 | 5 Wed May 12 19:52:05 PDT 2004=====>[~/temp]
hanzo@scimd: pts/0: 25 files 37Mb-> cat onethird.c
#include
main()
{
double a, b;
a = 1.e0;
b = 3.e0;
printf("%18.16lf\n", a/b);
}
Wed May 12 19:52:10 PDT 2004=====>[~/temp]
hanzo@scimd: pts/0: 25 files 37Mb-> gcc -o onethird.exe onethird.c
Wed May 12 19:52:13 PDT 2004=====>[~/temp]
hanzo@scimd: pts/0: 25 files 37Mb-> ./onethird.exe
0.3333333333333333
123456789ABCDEF0
十六个三了吧。
Wed May 12 19:52:17 PDT 2004=====>
【在 w****n 的大作中提到】 : 忘记说了,一定要用C++/C : : 不论什么complior
|
a******s 发帖数: 232 | 6 meaningless work
【在 w****n 的大作中提到】 : 忘记说了,一定要用C++/C : : 不论什么complior
|
w****n 发帖数: 31 | 7 what did u mean?
【在 a******s 的大作中提到】 : meaningless work
|
h***o 发帖数: 539 | 8 hanzo@scimd: pts/0: 25 files 37Mb-> cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 9
model name : Intel(R) Pentium(R) M processor 1400MHz
stepping : 5
cpu MHz : 1395.881
cache size : 1024 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr mce cx8 sep m
【在 h***o 的大作中提到】 : Wed May 12 19:52:05 PDT 2004=====>[~/temp] : hanzo@scimd: pts/0: 25 files 37Mb-> cat onethird.c : #include : main() : { : double a, b; : a = 1.e0; : b = 3.e0; : printf("%18.16lf\n", a/b); : }
|
w****n 发帖数: 31 | 9 我是需要多于16个3。如果是double, 最多16个3。
【在 h***o 的大作中提到】 : Wed May 12 19:52:05 PDT 2004=====>[~/temp] : hanzo@scimd: pts/0: 25 files 37Mb-> cat onethird.c : #include : main() : { : double a, b; : a = 1.e0; : b = 3.e0; : printf("%18.16lf\n", a/b); : }
|
w****n 发帖数: 31 | 10 what are you doing? u can only obtain 16 "3". :)
clflush dts acpi mmx fxsr sse sse2 tm pbe tm2 est
【在 h***o 的大作中提到】 : hanzo@scimd: pts/0: 25 files 37Mb-> cat /proc/cpuinfo : processor : 0 : vendor_id : GenuineIntel : cpu family : 6 : model : 9 : model name : Intel(R) Pentium(R) M processor 1400MHz : stepping : 5 : cpu MHz : 1395.881 : cache size : 1024 KB : fdiv_bug : no
|
|
|
h***o 发帖数: 539 | 11 那没戏,让(1.0+t == 1.0)为真的最大t值,在pentium机里差不多就是3e-17左右
所以没戏吧。
【在 w****n 的大作中提到】 : 我是需要多于16个3。如果是double, 最多16个3。
|
h***o 发帖数: 539 | 12 look at this one
hanzo@scimd: pts/0: 25 files 37Mb-> gcc -o onethird.exe onethird.c
Wed May 12 20:00:26 PDT 2004=====>[~/temp]
hanzo@scimd: pts/0: 25 files 37Mb-> ./onethird.exe
0.333333333333333314829616256247390992939472198486328125
I am pretty sure there are more than sixteen '3's....hoho
【在 w****n 的大作中提到】 : what are you doing? u can only obtain 16 "3". :) : : clflush dts acpi mmx fxsr sse sse2 tm pbe tm2 est
|
t*****e 发帖数: 13 | 13 Why C?
I got more than 20 using fortran
program main
real :: c
c = 1./3.
print'(F22.20)',c
end
using ifc7.1
ifc -r16 -pc80 test.f90
./a.out
0.33333333333333333333(20 '3's)
【在 w****n 的大作中提到】 : 忘记说了,一定要用C++/C : : 不论什么complior
|
w****n 发帖数: 31 | 14 it depends on ur data type. GSL has extended precision IEEE ... but it's not
working in my PC/Suse.所以我想来这里问问有什么高人知道怎么干。
【在 h***o 的大作中提到】 : 那没戏,让(1.0+t == 1.0)为真的最大t值,在pentium机里差不多就是3e-17左右 : 所以没戏吧。
|
w****n 发帖数: 31 | 15 这是我最想不通的事情。居然c/c++没有办法得到这样的double precision(extended
precision)?????
【在 t*****e 的大作中提到】 : Why C? : I got more than 20 using fortran : program main : real :: c : c = 1./3. : print'(F22.20)',c : end : using ifc7.1 : ifc -r16 -pc80 test.f90 : ./a.out
|
a******s 发帖数: 232 | 16
-pc80好像没用吧?
【在 t*****e 的大作中提到】 : Why C? : I got more than 20 using fortran : program main : real :: c : c = 1./3. : print'(F22.20)',c : end : using ifc7.1 : ifc -r16 -pc80 test.f90 : ./a.out
|
h***o 发帖数: 539 | 17 16字节的real算起来巨慢,这个我有经验
我要不把那部分改了,再给我5年我也不可能毕业
【在 t*****e 的大作中提到】 : Why C? : I got more than 20 using fortran : program main : real :: c : c = 1./3. : print'(F22.20)',c : end : using ifc7.1 : ifc -r16 -pc80 test.f90 : ./a.out
|
a******s 发帖数: 232 | 18 你看看thinkme是怎么编译的,再看看hanzo那程序写法和编译法,就知道为什么了.:)
【在 w****n 的大作中提到】 : 这是我最想不通的事情。居然c/c++没有办法得到这样的double precision(extended : precision)?????
|
w****n 发帖数: 31 | 19 no. thinkme 用的是fortran. 和hanzo不是一回事情。
【在 a******s 的大作中提到】 : 你看看thinkme是怎么编译的,再看看hanzo那程序写法和编译法,就知道为什么了.:)
|
a******s 发帖数: 232 | 20 我c和fortran还是能看出来的:),语言是区别,但是不是本质。
【在 w****n 的大作中提到】 : no. thinkme 用的是fortran. 和hanzo不是一回事情。
|
|
|
w****n 发帖数: 31 | 21 我就是找不到用gcc 编译的时候,如果我的data type在程序里是long double, 我是否要
在编译的时候加一些flag.
【在 t*****e 的大作中提到】 : Why C? : I got more than 20 using fortran : program main : real :: c : c = 1./3. : print'(F22.20)',c : end : using ifc7.1 : ifc -r16 -pc80 test.f90 : ./a.out
|
w****n 发帖数: 31 | 22 so, please tell me how to get it work in C, or it's just not going to work in
C. I will really appreicate. :)
.:)
【在 a******s 的大作中提到】 : 我c和fortran还是能看出来的:),语言是区别,但是不是本质。
|
a******s 发帖数: 232 | 23 hanzo用的是gcc,是没有-r8 or -r16这样的选项的,他程序里面是double,这样就
相当于thinkme用-r8做出来的,而thinkme实际上用的是-r16,当然就比hanzo的高了,
但是-r16也是有限度的,
$ ./a.out
0.3333333333333333333333333333333333173000
解决的办法就是改gcc为icc,这样我估计就可以做到了,程序都是一样的,但是
declare的不同,当然结果就不同了。
【在 w****n 的大作中提到】 : so, please tell me how to get it work in C, or it's just not going to work in : C. I will really appreicate. :) : : .:)
|
t*****e 发帖数: 13 | 24 I cant make long double work properly using g++
here is the code
#include
int main()
{
long double a;
a = 1.0/3.0;
printf("%22.20lf\n",a);
return 0;
}
here is the output:
-0.00000000000000000000
which is obviously wrong.
If I use double, the output is:
0.33333333333333331483
still 16 '3's but not more than that
【在 w****n 的大作中提到】 : so, please tell me how to get it work in C, or it's just not going to work in : C. I will really appreicate. :) : : .:)
|
h***o 发帖数: 539 | 25 gcc用long double能搞到19位3
hanzo@scimd: pts/0: 26 files 37Mb-> ./onethird.exe
0.3333333333333333333423683514
加了-m128bit-long-double好象还是这么多
【在 a******s 的大作中提到】 : hanzo用的是gcc,是没有-r8 or -r16这样的选项的,他程序里面是double,这样就 : 相当于thinkme用-r8做出来的,而thinkme实际上用的是-r16,当然就比hanzo的高了, : 但是-r16也是有限度的, : $ ./a.out : 0.3333333333333333333333333333333333173000 : 解决的办法就是改gcc为icc,这样我估计就可以做到了,程序都是一样的,但是 : declare的不同,当然结果就不同了。
|
h***o 发帖数: 539 | 26
%22.20Lf
【在 t*****e 的大作中提到】 : I cant make long double work properly using g++ : here is the code : #include : int main() : { : long double a; : a = 1.0/3.0; : printf("%22.20lf\n",a); : return 0; : }
|
w****n 发帖数: 31 | 27 hi, achillis, and thinkme and all:
thank you very much for helping out. it does sound like that i should try
icc. make sense. but what's the flag i shall use?
or any icc manual?
in
【在 a******s 的大作中提到】 : hanzo用的是gcc,是没有-r8 or -r16这样的选项的,他程序里面是double,这样就 : 相当于thinkme用-r8做出来的,而thinkme实际上用的是-r16,当然就比hanzo的高了, : 但是-r16也是有限度的, : $ ./a.out : 0.3333333333333333333333333333333333173000 : 解决的办法就是改gcc为icc,这样我估计就可以做到了,程序都是一样的,但是 : declare的不同,当然结果就不同了。
|
w****n 发帖数: 31 | 28 hi, hanzo,你是怎么搞到19位的????with what flag??
,
work in
【在 h***o 的大作中提到】 : gcc用long double能搞到19位3 : hanzo@scimd: pts/0: 26 files 37Mb-> ./onethird.exe : 0.3333333333333333333423683514 : 加了-m128bit-long-double好象还是这么多
|
a******s 发帖数: 232 | 29 install icc if you want to use c, ifc for fortran. You will find the document
in the doc directory. It should come with icc.
【在 w****n 的大作中提到】 : hi, achillis, and thinkme and all: : thank you very much for helping out. it does sound like that i should try : icc. make sense. but what's the flag i shall use? : or any icc manual? : : in
|
h***o 发帖数: 539 | 30
man了一下gcc就明白了
-m128bit-long-double
These switches control the size of "long double" type. The i386
application binary interface specifies the size to be 96 bits, so
-m96bit-long-double is the default in 32 bit mode.
Modern architectures (Pentium and newer) would prefer "long double"
to be aligned to an 8 or 16 byte boundary. In arrays or structures
conforming to the ABI, this would not be possible. So specifying a
-m
【在 h***o 的大作中提到】 : gcc用long double能搞到19位3 : hanzo@scimd: pts/0: 26 files 37Mb-> ./onethird.exe : 0.3333333333333333333423683514 : 加了-m128bit-long-double好象还是这么多
|
|
|
a******s 发帖数: 232 | 31 还是没我的多:)
【在 h***o 的大作中提到】 : gcc用long double能搞到19位3 : hanzo@scimd: pts/0: 26 files 37Mb-> ./onethird.exe : 0.3333333333333333333423683514 : 加了-m128bit-long-double好象还是这么多
|
h***o 发帖数: 539 | 32 no flag needed....just use long double
printf use %Lf instead of %lf
【在 w****n 的大作中提到】 : hi, hanzo,你是怎么搞到19位的????with what flag?? : : , : work in
|
w****n 发帖数: 31 | 33 no, it's working here:
wilson@mary015-01dhcp57:~/program/PRECISION> more long.c
#include
int main()
{
long double a;
a = 1.0/3.0;
printf("%22.20Lf\n",a);
return 0;
}
wilson@mary015-01dhcp57:~/program/PRECISION> gcc long.c
wilson@mary015-01dhcp57:~/program/PRECISION> ./a.out
0.33333333333333331483
【在 h***o 的大作中提到】 : no flag needed....just use long double : printf use %Lf instead of %lf
|
h***o 发帖数: 539 | 34 你这个gcc太土了吧。hoho
hanzo@scimd: pts/0: 26 files 37Mb-> gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: /var/tmp/portage/gcc-3.3.3-r3/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 |
w****n 发帖数: 31 | 35 here it is:
wilson@mary015-01dhcp57:~/program/PRECISION> gcc -v
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.1/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr |
h***o 发帖数: 539 | 36 要么是版本太低,要么是有些开关编译的时候没打开,比如 |
a******s 发帖数: 232 | 37
这个是有可能的,编译器编译的时候有很多options的。
gentoo宰牛也没有icc牛,呵呵
我试了fedora的gcc
$ gcc a.c
$ ./a.out
0.33333333333333331483
#include
int main()
{
long double a;
a = 1.0/3.0;
printf("%22.20Lf\n",a);
return 0;
}
【在 h***o 的大作中提到】 : 要么是版本太低,要么是有些开关编译的时候没打开,比如
|
a******s 发帖数: 232 | 38 $ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
【在 a******s 的大作中提到】 : : 这个是有可能的,编译器编译的时候有很多options的。 : gentoo宰牛也没有icc牛,呵呵 : 我试了fedora的gcc : $ gcc a.c : $ ./a.out : 0.33333333333333331483 : #include : int main() : {
|
w****n 发帖数: 31 | 39 i just tried redhat gcc, it's not working. :(( hehe
【在 a******s 的大作中提到】 : $ gcc -v : Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.2/specs : Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux : Thread model: posix : gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
|
a******s 发帖数: 232 | 40 icc比gcc快多了,功能也多不少,尤其是-r选项,这么方便的东西为啥不用呢?
我都说了解决办法了,即使你重装机器,装gentoo的话,gentoo上的gcc也不比
icc快,何苦呢?:)
【在 w****n 的大作中提到】 : i just tried redhat gcc, it's not working. :(( hehe
|
|
|
w****n 发帖数: 31 | 41 hehe. achillis,这个问题我搞了很久乐, 现在特别好奇.就想try try. i actually
like ur solution best.
我现在就是有点好奇,怎么hanzo的gcc 能work呢? 其实20个3对我刚刚好。呵呵。
【在 a******s 的大作中提到】 : icc比gcc快多了,功能也多不少,尤其是-r选项,这么方便的东西为啥不用呢? : 我都说了解决办法了,即使你重装机器,装gentoo的话,gentoo上的gcc也不比 : icc快,何苦呢?:)
|
a******s 发帖数: 232 | 42
没什么好奇的,gentoo编译gcc的时候可能打开了那个option,kaka,如果你够坚定,
可以自己编个gcc和hanzo抗衡,kaka
【在 w****n 的大作中提到】 : hehe. achillis,这个问题我搞了很久乐, 现在特别好奇.就想try try. i actually : like ur solution best. : 我现在就是有点好奇,怎么hanzo的gcc 能work呢? 其实20个3对我刚刚好。呵呵。
|
h***o 发帖数: 539 | 43 你难道不知道现在amd的cpu比intel的卖得多?
【在 a******s 的大作中提到】 : icc比gcc快多了,功能也多不少,尤其是-r选项,这么方便的东西为啥不用呢? : 我都说了解决办法了,即使你重装机器,装gentoo的话,gentoo上的gcc也不比 : icc快,何苦呢?:)
|
a******s 发帖数: 232 | 44 做数值计算,我只用intel,kaka,管什么amd? amd现在和intel差多少钱了?
【在 h***o 的大作中提到】 : 你难道不知道现在amd的cpu比intel的卖得多?
|
a******s 发帖数: 232 | 45 其实,你需不需要那么多位这才是我第一个回帖的意思。这个比icc还重要,kaka
【在 w****n 的大作中提到】 : hehe. achillis,这个问题我搞了很久乐, 现在特别好奇.就想try try. i actually : like ur solution best. : 我现在就是有点好奇,怎么hanzo的gcc 能work呢? 其实20个3对我刚刚好。呵呵。
|
f****r 发帖数: 27 | 46 AMD is simply faster :)
【在 a******s 的大作中提到】 : 做数值计算,我只用intel,kaka,管什么amd? amd现在和intel差多少钱了?
|