ÔÚJavaÖÐʵÏÖ¸¡µãÊýµÄ¾«È·¼ÆËã
±êÌâ ÔÚJavaÖÐʵÏÖ¸¡µãÊýµÄ¾«È·¼ÆËã AYellow£¨Ô×÷£© ÐÞ¸Ä
¹Ø¼ü×Ö Java ¸¡µãÊý ¾«È·¼ÆËã
ÎÊÌâµÄÌá³ö£º
Èç¹ûÎÒÃDZàÒëÔËÐÐÏÂÃæÕâ¸ö³ÌÐò»á¿´µ½Ê²Ã´£¿
public class Test{
public static void main(String args[]){
System.out.println(0.05+0.01);
System.out.println(1.0-0.42);
System.out.println(4.015*100);
System.out.println(123.3/100);
}
};
ÄãûÓп´´í£¡½á¹ûȷʵÊÇ
0.060000000000000005
0.5800000000000001
401.49999999999994
1.2329999999999999
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Ò²²»Äܽâ¾öÕâ¸öÎÊÌ⣺
System.out.println(new java.text.DecimalFormat("0.00").format(4.025));
Êä³öÊÇ4.02
BigDecimal
ÔÚ¡¶Effective Java¡·Õâ±¾ÊéÖÐÒ²Ìáµ½Õâ¸öÔÔò£¬floatºÍdoubleÖ»ÄÜÓÃÀ´×ö¿Æѧ¼ÆËã»òÕßÊǹ¤³Ì¼ÆË㣬ÔÚÉÌÒµ¼ÆËãÖÐÎÒÃÇÒªÓÃjava.math.BigDecimal¡£BigDecimalÒ»¹²ÓÐ4¸ö¹»Ôì·½·¨£¬ÎÒÃDz»¹ØÐÄÓÃBigIntegerÀ´¹»ÔìµÄÄÇÁ½¸ö£¬ÄÇô»¹ÓÐÁ½¸ö£¬ËüÃÇÊÇ£º
BigDecimal(double val)
 
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
1. Ê×ÏÈString²»ÊôÓÚ8ÖÖ»ù±¾Êý¾ÝÀàÐÍ£¬StringÊÇÒ»¸ö¶ÔÏó¡£
ÒòΪ¶ÔÏóµÄĬÈÏÖµÊÇnull£¬ËùÒÔStringµÄĬÈÏÖµÒ²ÊÇnull£»µ«ËüÓÖÊÇÒ»ÖÖÌØÊâµÄ¶ÔÏó£¬ÓÐÆäËü¶ÔÏóûÓеÄһЩÌØÐÔ¡£
2. new String()ºÍnew String(“”)¶¼ÊÇÉêÃ÷Ò»¸öеĿÕ×Ö·û´®£¬ÊÇ¿Õ´®²»ÊÇnull£»
3. String str=”kvill”£»
String str=n ......
JavaÖеÄreturnÓï¾ä×ÜÊǺͷ½·¨ÓÐÃÜÇйØϵ£¬returnÓï¾ä×ÜÊÇÓÃÔÚ·½·¨ÖУ¬ÓÐÁ½¸ö×÷Óã¬Ò»¸öÊÇ·µ»Ø·½·¨Ö¸¶¨ÀàÐ͵ÄÖµ(Õâ¸öÖµ×ÜÊÇÈ·¶¨µÄ)£¬Ò»¸öÊǽáÊø·½·¨µÄÖ´ÐÐ(½ö½öÒ»¸öreturnÓï¾ä)¡£
¡¡¡¡ÔÚreturnÓï¾äµÄ¸÷ÀàÎÄÕÂÖУ¬´ó¶à½ö½ö½éÉÜÁËreturnÓï¾äÓÃÓÚÓзµ»ØÖµ(·Çvoid·µ»ØÖµ)µÄ·½·¨ÖС£¶øºÜÉÙ»òûÓнéÉÜreturnÓï¾äÔÚvodi·µ»ØÖµ·½·¨ ......
½ñÌìÔÙÂÛ̳¿´µ½ÁËÓÐÈËÎÊJAVAÃüÃû¹æ·¶£¬ÎÒ¾õµÃÕâ¸öÎÊÌâµÄÈ·ÐèҪעÖØÒ»ÏÂ
ÒòΪ¶ÔÓÚÒ»¸ö³ÌÐòÀ´Ëµ ³ÌÐòµÄ¸ñʽÊǷdz£ÖØÒª£¬Ãû×ÖÆð³ÉʲôÑù¿ÉÒÔ¿´³öÕâ¸öÈ˵ıà³ÌÄÜÁ¦£¬
Èç¹ûÒ»¸öÈ˵ijÌÐòдµÄ·Ç³£µÄÂÒ£¬Ãû×Öûһµã¹æ·¶µÄ»°»á¾õµÃ³ÌÐòºÜ"³ó"£¬Õâ»áÈöÁÕ߸ù±¾Ã»
ÐÄ˼ÍùÏ¿´
ÏÂÃæÕª×ÔÂÛ̳һÍøÓѶÔÃüÃû¹æ·¶µÄ×ܽ᣺
1.°ü
ÓÉСР......
Javaµ±ÖеÄÐòÁл¯£¬ÆäÖ÷ÒªµÄ×÷ÓÃÊǽ«ÀàµÄʵÀý½øÐÐÎÞËð´«Ê䣬»òÕß˵¾ÍÊÇͨ¹ýJavaµÄÐòÁл¯»úÖÆ£¬JavaÀàµÄʵÀý¿ÉÒÔͨ¹ýObjectÁ÷À´´«ÊäºÍÖØлñÈ¡£¬¶ø²»»áËð»µÀàµÄʵÀý¡£
Ê×ÏÈ£¬ÎÒÃÇ¿´¿´Ê²Ã´ÑùµÄÀàÊÇÐòÁл¯À࣬
1.AÀà×ÔÉíʵÏÖÁËSerializable½Ó¿ÚµÄÀࣻ ......