🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #12637

Re: ���,�����ô��true?

#12637
From: Only YOU
Date: Thu, 22 Jul 2004 17:02
65 lines
5266 bytes
   �Ҿ���������ģ��㿴���Է�
    ��д�� ������ֱ��ǣ�bbs1    bbs2
    public class bbs1{
    public static void main(String args[]){
        double a2 = 1.0, b2 = -0��//p1
        float c2 = 1.0f, d2 = 0.0f,e2=-0.0f;//p7
        System.out.println(a2/b2);//p2
        System.out.println((c2/d2));//p3
        System.out.println(b2==d2);//p4
        System.out.println(d2==e2);//p5
        System.out.println((a2/b2)==(c2/d2));//p6
    }
}   
public class bbs2{
    public static void main(String args[]){
        double a2 = 1.0, b2 = -0.0;//p1
        float c2 = 1.0f, d2 = 0.0f,e2=-0.0f;//p7
        System.out.println((a2/b2));//p2
        System.out.println((c2/d2));//p3
        System.out.println(b2==d2);//p4
        System.out.println(d2==e2);//p5
        System.out.println((a2/b2)==(c2/d2));//p6
    }
}
       ���ȣ�������ȱ��벢����һ��bbs2���������Ӧ��������Ҫ�Ľ��
    -Infinity            
     Infinity                      �ɴ˿��Իش���float��double��Infinityһ��
     true                          ���ҿ��ԱȽ�,�����������Ƿ���෴
     true                          ���ԣ�Ϊfalse
     false                             ���ܺ��?
       Ȼ���������벢����bbs1,����ǣ�
     Infinity                       ���� p6����Ľ��true���������ʵİ�
     Infinity                       ��������ϰ���ͻᷢ�֣���Ϊp2,p3�Ľ��һ��
     true                           ����p6��ȻΪtrue��
     true
     true
              ����Ϊʲô��bbs1��bbs2��p2��p6�Ķ�Ӧ���ͬ�أ���
   ������bbs1,bbs2����������2�ߵ�p1��b2�ĸ�ֵ��ʽ��ͬ���ֱ��ǣ�
    double b2 = -0;   ��double b2 = -0.0;  
  ���ں���û���⣬����ǰ�߾��漰��������ת���������Զ϶�����ͳ��������
  ��0 �������� int ,��int�ķ�Χ��-231��230,����-231��-1��0��230,��û�У�0
  Ҳ����˵,�����д-0�ᱻ��Ϊ����0�������double b2 = 0;��double b2=0.0;
   ��һ��ģ�Ӧ��û����ɣ���ôbbs1�е�p2��p6�����ҲӦ��֪��Ϊʲô�˰ɣ���
   �������������������Ҿ���Ӧ�ö�����˰ɡ������������Dz�֪�����Dz���
   �ֲ�����һ���µ����⣬�Ǿ��ǣ�float�ķ�Χ��-3.403E38��3.403E38
   double�ķ�Χ��-1.798E308��1.798E308 ˵�������͵Ĵ���-0.0��0.0
   ���int������Ϊ������-0������-0����0����ô�����ʹ���-0.0���Ƿ񻹵���0.0 ��
    �ҵ�����������һ�λ�����������и���-0.0�����ֵ������+0.0��ȡ�����
   ���ǵ�ֵ��ȣ�����������ᵼ�²�ͬ�Ľ�����磺1.0f/0.0f����������
   1.0f/-0.0f���ڸ�����������Ľ���ǵ���-0.0����-0.0=0.0����ô������֤
   �����أ���������ŵ�һ�������صı��ʽ�У�����Ľ��Ϳ�����֤��������
   �㻹�Ǹ����ˡ����磬���X�����㣬�����ʽ1/X�����������ʱ����ôX��������
    ��֮�� �Ǹ��㡣

             �Ǻǣ�����˵������ɣ��в��׵ĵط�ϣ��ָ�����д裬�д裡    
 
 �� arson (ż�����ϵġ�) �Ĵ������ᵽ: ��
:    double a2 = 1.0, b2 = -0;
:    float c2 = 1.0f, d2 = 0.0f;
:    System.out.println(((a2/b2)==(c2/d2)));      //why this "true"??
:    float��infinity ��long��infinity һ���ô? ���Ա�ô?  ���� �������෴��
: ô��true??????
--
�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 202.118.99.71]
Technical Details
Message-ID: <4DKVkf$9qV@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp-server.pubsub.com!maily.cic.tsinghua.edu.cn!netnews.sdu.edu.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,eb3eea099c74524f
X-Google-Attributes: gidf6cb0,public
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp-server.pubsub.com!maily.cic.tsinghua.edu.cn!netnews.sdu.edu.cn!SJTU
From: JamesGeng.bbs@bbs.sjtu.edu.cn ( Only YOU)
Newsgroups: cn.bbs.comp.lang.java
Subject: Re: ���,�����ô��true?
Date: 22 Jul 2004 17:02:53 GMT
Organization: ��ˮ˼Դ
Message-ID: <4DKVkf$9qV@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: Java/M.1090510793.A
Lines: 65