Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaÖÐfloat/double¸¡µãÊýµÄ¼ÆËãʧ¾«¶ÈÎÊÌâ

 javaÖи¡µãÊýµÄ¼ÆËã
½ñÌìÔÚÊýÖµ¼ÆËãʱÅöµ½Ò»¸öÎÊÌâ.³ÌÐòÈçÏÂ:
  double a = (3.3-2.4)/0.1;
  System.out.println(a);
Äã¿ÉÄÜÈÏΪ½á¹ûºÜ¼òµ¥,²»¾ÍÊÇ9Âï,ÊÇÊÂʵÉÏ,½á¹ûΪ:8.999999998,ΪʲôÄØ?ÎÒ·­ÔÄÁËһЩ×ÊÁÏ,ÖÕÓÚÕÒ³öÁËÔ­Òò.
Ϊʲô¸¡µãÊý»á¶ªÊ§¾«¶È£¿ 
Ê®½øÖÆÊýµÄ¶þ½øÖƱíʾ¿ÉÄܲ»¹»¾«È·
¸¡µãÊý»òÊÇË«¾«¶È¸¡µãÊýÎÞ·¨¾«È·±íʾµÄÇé¿ö²¢²»ÉÙ¼û¡£¸¡µãÊýֵû°ì·¨ÓÃÊ®½øÖÆÀ´¾«È·±íʾµÄÔ­ÒòÒª¹é¾ÌÓÚCPU±íʾ¸¡µãÊýµÄ·½·¨¡£ÕâÑùµÄ»°Äú¾Í¿ÉÄÜ»áÎþÉüһЩ¾«¶È£¬ÓÐЩ¸¡µãÊýÔËËãÒ²»áÒýÈëÎó²î¡£ÒÔÉÏÃæÌáµ½µÄÇé¿öΪÀý£¬2.4µÄ¶þ½øÖƱíʾ²¢·Ç¾ÍÊǾ«È·µÄ2.4¡£·´¶ø×îΪ½Ó½üµÄ¶þ½øÖƱíʾÊÇ 2.3999999999999999¡£Ô­ÒòÔÚÓÚ¸¡µãÊýÓÉÁ½²¿·Ö×é³É£ºÖ¸ÊýºÍβÊý¡£¸¡µãÊýµÄֵʵ¼ÊÉÏÊÇÓÉÒ»¸öÌض¨µÄÊýѧ¹«Ê½¼ÆËãµÃµ½µÄ¡£ÄúËùÓöµ½µÄ¾«¶ÈËðʧ»áÔÚÈκβÙ×÷ϵͳºÍ±à³Ì»·¾³ÖÐÓöµ½¡£
×¢Ò⣺ Äú¿ÉÒÔʹÓÃBinary Coded Decimal (BCD)¿âÀ´±£³Ö¾«¶È¡£BCDÊý×Ö±àÂë·½·¨»á°Ñÿһ¸öÊ®½øÖÆÊý×Öλµ¥¶À±àÂë¡£ 
ÀàÐÍʧÅä
Äú¿ÉÄÜ»ìºÏÁ˸¡µãÊýºÍË«¾«¶È¸¡µãÊýÀàÐÍ¡£ÇëÈ·¶¨ÄúÔÚ½øÐÐÊýѧÔËËãµÄʱºòËùÓеÄÊý¾ÝÀàÐÍÈ«²¿Ïàͬ¡£
×¢Ò⣺floatÀàÐ͵ıäÁ¿Ö»ÓÐ7λµÄ¾«¶È£¬¶ødoubleÀàÐ͵ıäÁ¿ÓÐ15λµÄ¾«¶È¡£
ÈçºÎ½øÐи¡µãÊý¾«¶È¼ÆË㣿            
      JavaÖеļòµ¥¸¡µãÊýÀàÐÍfloatºÍdouble²»Äܹ»½øÐÐÔËËã¡£²»¹âÊÇJava£¬ÔÚÆäËüºÜ¶à±à³ÌÓïÑÔÖÐÒ²ÓÐÕâÑùµÄÎÊÌâ¡£ÔÚ´ó¶àÊýÇé¿öÏ£¬¼ÆËãµÄ½á¹ûÊÇ׼ȷµÄ£¬µ«ÊǶàÊÔ¼¸´Î£¨¿ÉÒÔ×öÒ»¸öÑ­»·£©¾Í¿ÉÒÔÊÔ³öÀàËÆÉÏÃæµÄ´íÎó¡£ÏÖÔÚÖÕÓÚÀí½âΪʲôҪÓÐBCDÂëÁË¡£
Õâ¸öÎÊÌâÏ൱ÑÏÖØ£¬Èç¹ûÄãÓÐ9.999999999999Ôª£¬ÄãµÄ¼ÆËã»úÊDz»»áÈÏΪÄã¿ÉÒÔ¹ºÂò10ÔªµÄÉÌÆ·µÄ¡£
ÔÚÓеıà³ÌÓïÑÔÖÐÌṩÁËרÃŵĻõ±ÒÀàÐÍÀ´´¦ÀíÕâÖÖÇé¿ö£¬µ«ÊÇJavaûÓС£ÏÖÔÚÈÃÎÒÃÇ¿´¿´ÈçºÎ½â¾öÕâ¸öÎÊÌâ¡£
 
ËÄÉáÎåÈë
ÎÒÃǵĵÚÒ»¸ö·´Ó¦ÊÇ×öËÄÉáÎåÈë¡£MathÀàÖеÄround·½·¨²»ÄÜÉèÖñ£Áô¼¸Î»Ð¡Êý£¬ÎÒÃÇÖ»ÄÜÏóÕâÑù£¨±£ÁôÁ½Î»£©£º
public double round(double value){
    return Math.round(value*100)/100.0;
}
·Ç³£²»ÐÒ£¬ÉÏÃæµÄ´úÂë²¢²»ÄÜÕý³£¹¤×÷£¬¸øÕâ¸ö·½·¨´«Èë4.015Ëü½«·µ»Ø4.01¶ø²»ÊÇ4.02£¬ÈçÎÒÃÇÔÚÉÏÃæ¿´µ½µÄ
4.015*100=401.49999999999994
Òò´ËÈç¹ûÎÒÃÇÒª×öµ½¾«È·µÄËÄÉáÎåÈ룬²»ÄÜÀûÓüòµ¥ÀàÐÍ×öÈκÎÔËËã
java.text.DecimalFormatÒ²²»Äܽâ¾öÕâ¸öÎÊÌâ


Ïà¹ØÎĵµ£º

Java BeanÔ­ÀíÓëÓ¦ÓÃ

   ¡¡¡¡1¡¢Ê²Ã´ÊÇJavaBean£¿  
   
  ¡¡¡¡JavaBeanÊÇÃèÊöJavaµÄÈí¼þ×é¼þÄ£ÐÍ£¬ÓеãÀàËÆÓÚMicrosoftµÄCOM×é¼þ¸ÅÄî¡£ÔÚJavaÄ£ÐÍÖУ¬Í¨¹ýJavaBean¿ÉÒÔÎÞÏÞÀ©³äJava³ÌÐòµÄ¹¦ÄÜ£¬Í¨¹ýJavaBeanµÄ×éºÏ¿ÉÒÔ¿ìËÙµÄÉú³ÉеÄÓ¦ÓóÌÐò¡£¶ÔÓÚ³ÌÐòÔ±À´Ëµ£¬×îºÃµÄÒ»µã¾ÍÊÇJavaBean¿ÉÒÔʵÏÖ´úÂëµÄÖظ´ÀûÓ ......

java»ñÈ¡SQL²éѯ½á¹û¼¯ÖеÄÐÐÊýºÍÁÐÊý

http://cheneyph.javaeye.com/blog/477829
         ÔÚJavaÖУ¬»ñµÃResultSetµÄ×ÜÐÐÊýµÄ·½·¨ÓÐÒÔϼ¸ÖÖ¡£
µÚÒ»ÖÖ£ºÀûÓÃResultSetµÄgetRow·½·¨À´»ñµÃResultSetµÄ×ÜÐÐÊý
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABL ......

Java»æͼ

ÏÂÃæÊÇÎÒÈÏΪÕýÈ·µÄ×ö·¨£¨½áºÏ×Ô¼ºµÄ¾­ÑéдµÄ£¬Èç¹û²»ÕýÈ·£¬Çë´ó¼ÒÖ¸Õý£©£º
ÎҵĻæͼ¿Ø¼þÊÇJPanel£¬
³öÏÖ¹ö¶¯ÌõµÄÇ°Ìᣬ±ØÐëÈûæͼ¿Ø¼þ·ÅÔÚJScrollPaneÉÏ£¬
¶ÔÓÚJScrollPaneµÄLayout£¬Ã»ÓÐÌØÊâÒªÇó£¬ÏÂÃæÕâÑù¼´¿É£º
jScrollPane1.setViewportView(jPanel1);
È»ºó£¬ÁíÍâά³ÖÒ»¸öBufferedImage£¨¼ÙÉè½Ðimage1£©£¬¸÷ÖÖÍ¼Ï ......

Java HashMapºÍTreeMapµÄÅÅÐòÎÊÌâ×ܽá

Map´æ´¢µÄÊÇkey->valueµÄÖµ¶Ô£¬keyµÄÖµÊÇΨһµÄ£¬¶øvalueµÄÖµ¿ÉÒÔÖظ´¡£Í¨³£Ê¹ÓõÄÊÇHashMap»òTreeMap£¬Èç¹û¿¼ÂÇÐÔÄÜ£¬Ê¹ÓÃHashMap¡£TreeMapʹÓúìºÚÊ÷ʵÏÖ£¬±£ÁôÓÐkeyֵ˳ÐòÐÔ£¬»á×Ô¶¯°´ÕÕkeyÖµÅÅÐò¡£
ĬÈÏÊÇ°´ÕÕkeyÖµµÄÉýÐòÅÅÐò£¬keyÖµ±ØÐëʵÏÖ Comparator½Ó¿Ú¡£Èç¹ûÏ£Íû°´ÕÒÒ»¶¨¹æÔòÅÅÐò£¬ÔòÐèÒªÖØж¨Òåcompareº¯Êý ......

SolarisÏÂjava packageµÄ±àÒëÓëÔËÐÐ

Õ⼸ÌìÓöµ½ÁËjavaµÄpackageÎÊÌ⣨ÕâÖÖÎÊÌâÖ»ÊÇÔÚcmdÃüÁîÐÐģʽÏ»áÓöµ½£¬Èç¹ûÓÃeclipse¾Í²»»áÓÐÕâÖÖÎÊÌ⣩£¬°ÑjavaÖеÄpackage±àÒëÔËÐеÄÎÊÌâ×ܽáһϣ¬×÷Ϊ±¸Íü¡£
    Ê×ÏÈ£¬Èç¹ûÄãÓÐÁ½¸öÀࣺ
   £¨1£©A.java
        import edu.ustc.*;
  &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ