æµ®åå°æ°ç¹æ°
ECMAScriptã®æµ®åå°æ°ç¹æ°ã®ä¸¸ãé¢æ°ã§ãã Number.prototype.toFixed() ã«ã¤ãã¦èª¿ã¹ã¦ã¿ãã¨ãããæµ®åå°æ°ç¹æ°ãããã£ã¦ãã人ãä½ã£ã硬派ãªä»æ§ã ã¨æããã®ã§ã解説ãã¦ã¿ã¾ãã æµ®åå°æ°ç¹æ°ã®ä¸¸ãã®åãæªãã«ã¤ã㦠ç§ã¯ããã°ã©ãã³ã°è¨èªã®æµ®åâ¦
MySQLã®ãã¼ã¿åã¨ãã¦FLOATåã¨ããåãããã®ã§ããããããæ¡ç¨ããã®ã¯æ··ä¹±ã®å ã§ã¯ãªããï¼ã¨æããã®ã§ããã®è©³ç´°ãç´¹ä»ãã¾ãã ãããããã®è©±ã®ãã£ããã¯ãMySQLã§6æ¡ã¾ã§ã®å°æ°ç¹ã丸ããã«æ±ããªãFLOATåã使ãã¹ãçç±ãã¨ããè¨äºãç®ã«æ¢ã¾â¦
ï¼7/3 14:05追è¨ï¼Javaã«é¢ããè¨è¿°ã«ã¤ãã¦èª¤èªããã£ãã®ã§ç大ã«æ¸ãæãã¾ãããJava 6ãJava 7ãJava 8ããããã§å®è£ ãå¤ãã£ã¦ããããã§ããï¼7/13 23:55追è¨ï¼æ¬è¨äºä¸ã§ã¯roundãåæ¨äºå ¥ã¨è¨ãåã£ã¦ãã¾ã£ã¦ãã¾ããããã¯çè ãC99ã®roundãåºâ¦
Monoã®roundé¢æ°ã«ãã°ãè¦ã¤ããããã¨ããæ¯åº¦ããªãã¿ã®è©±é¡ã§ãã æ©éã§ãããæµ®åå°æ°ç¹æ°ã§æ±ããä¸çªå¤§ããæ°ãæµ®åå°æ°ç¹æ°ä»¥ä¸ç¬¬2ä½ã§ä¸¸ãã¦ç¬¬1ä½ã¾ã§ã«ãã¦ã¿ã¾ãããã using System; class RoundingBigFloat { static void Main() { double d =â¦
C#ã®ä¸¸ãã¯åºæ¬çã«å¶æ°ä¸¸ãï¼banker's roundingï¼ã ã¨ããã®ãåã®èªèã§ãããdecimalã®æ°ãdoubleã«ãã£ã¹ãããã¨ãã«åæ¨äºå ¥ã«ãªãä¾ãããã¾ãããã¾ãã.NETç°å¢ã«éãæè¿æ¥ã®doubleã«ä¸¸ããããªãä¾ãè¦ã¤ãã¾ããã decimalããdoubleã¸ã®ãã£ã¹â¦
æµ®åå°æ°ç¹æ°ã®ä¸¸ãã«ããã¦ä¸¸ãæ¡æ°ãæå®ã§ããããã§ãã¦ç²¾åº¦ã失ããªããããªroundé¢æ°ãCã§å®è£ ãã¦ã¿ã¾ããã https://github.com/hnw/precise-round å®è£ ã¨ãã¦ã¯ãåãåã£ãæµ®åå°æ°ç¹æ°ããæçã«ãªã10é²è¡¨è¨ã«å¤æããæµ®åå°æ°ç¹ããºã©ããã¨ãªâ¦
(12/29 20:40追è¨)ãï¼è¿½è¨ï¼ãªãMySQLã®decimalåãä¾ã«ä½¿ã£ããã«ã¤ãã¦ãã¨ããã»ã¯ã·ã§ã³ã追å ãã¾ãããã¾ããã³ã¡ã³ããé æ´ããã®ã§è¿ä¿¡ãã¾ããã (12/29 21:30追è¨)C#ã«ã¤ãã¦è¨ãã°ãMath.Round ã¡ã½ãã (Double, Int32)ãã«å é¨å®è£ ãã©ããªã£â¦
7æ22æ¥ã«éå¬ããã第70åPHPåå¼·ä¼ã§çºè¡¨ãã¦ãã¾ããã以ä¸ãçºè¡¨è³æã§ãã æµ®åå°æ°ç¹æ°å¨ãã®ãããã¯ã3ç¹ç´¹ä»ããå 容ã§ããããæã£ãããåå¿ãè¯ãã£ãããã«æãã¾ãã ãã ãé¢ç½ãããã話ããã¨ãã¦ãèãã¦ããæ¹ã ã«ç¡é§ã«ææãä¸ãã¦ãã¾â¦
MySQL5.1ã®ã½ã¼ã¹ã³ã¼ãã確èªãã¦ããã¨ãããæµ®åå°æ°ç¹æ°ã®10é²è¡¨è¨ããæµ®åå°æ°ç¹æ°ã¸ã®å¤æå¦çã«å®è£ ä¸ã®åé¡ç¹ãè¦ã¤ãã¾ãããæµ®åå°æ°ç¹æ°å¦çã®å ¸åçãªè½ã¨ãç©´ã«ã¯ã¾ã£ã¦ãã¦ãè¨ç®ã®éä¸ã§ç²¾åº¦ãè½ã¨ãã¦ãã¾ã£ã¦ãã¾ãã ããã¯å¤ãããç¥ããâ¦
ç©ãããªæ¼ä¸ããã«MySQLã§å°æ°ã®è¶³ãç®ããã¦ããã¨ãããä¸æè°ãªç¾è±¡ãè¦ã¤ãã¾ããã mysql> select 0.8=0.7+0.1; +-------------+ | 0.8=0.7+0.1 | +-------------+ | 1 | +-------------+ 1 row in set (0.00 sec) mysql> select 0.8=0.7+0.1e0; +----â¦
å種ããã°ã©ãã³ã°è¨èªã«ã¯ãåãä¸ãã»åãæ¨ã¦ã»åæ¨äºå ¥ãªã©æµ®åå°æ°ç¹æ°ã丸ããé¢æ°ãä½ç¨®é¡ãããã¾ãããããã丸ãå¦çãå©ç¨ããéããceilã¨floorã©ã£ã¡ãã©ã£ã¡ã ã£ãï¼ãããã¤ãã¹ã®æ°ãæ¥ãæã®æåã£ã¦å¤§ä¸å¤«ãªãã ã£ãï¼ããªã©ã¨ä¸å®ã«ãªãâ¦
(2011/10/18 01:50)ãä»ã®è¨èªã§è©¦ãã¦ã¿ããã誰ãæ£ããã®ãï¼ãã追è¨ãã¾ãããã¾ããåå¿è ã¸ã®å¯¾çã¨å¼·èª¿ãããã¦èª¤è§£ãæããæ°ããããããå°ã表ç¾ãå¤æ´ãã¾ããã ååè¨äºãPHPã®roundé¢æ°ãèªã¿è§£ã (1)丸ãæ¡æ°ã大ãããã»å°ããããå ´åãã«â¦
PHP5.3.4ãã5.3.6ã®roundé¢æ°ã«åé¡ãããããããªãããã¨åããã°å ±åãã¦ãã件ï¼PHP :: Bug #54334ï¼ããPHP5.3.7ããä¿®æ£ããã¦ãã¾ããåã®ãã°ã¬ãã«ã¯ç¹ã«è¿äºããªãã®ã§ãå ¨ãç¬ç«ã«ä¿®æ£ããããã ã¨æãã¾ããPHP5.3.7ã®ChangeLogã«ã¯æ¬¡ã®ãããªâ¦
PHPã®roundé¢æ°ã¯PHP5.3.0ã§ä¸æ°ããã¾ãããããã®æåã¯è¤éã§ãã以åã®è¨äºãPHP5.3.0alpha3ã®roundé¢æ°ã®å®è£ ãPHP5.2.6ã¨å¤ãã£ããã§ã¯å ¸åçãªæåãç´¹ä»ãã¾ããããå®éã¯ããå°ãç´°ããå ´ååããããã¾ããåèªèº«ã®æ´çãå ¼ãã¦ãRFC*1ããã³PHPâ¦
PHP 5.3.0以éãPHPã®roundé¢æ°ã®æåã¯Christian Seilerãããææ¡ããRFCã«å¾ã£ã¦ä¸æ°ããã¦ãã¾ãããã®æ°ããroundé¢æ°ã®ä»æ§ä¸ã®åé¡ãããã¯ãã°ãè¦ã¤ãã¾ããã 以åã®è¨äºãPHP5.3.0alpha3ã®roundé¢æ°ã®å®è£ ãPHP5.2.6ã¨å¤ãã£ããã§ãã®æ°ããå®è£ â¦
Pythonã®roundé¢æ°ã«ãã°ããããã®ãè¦ã¤ããããã¨ããå ±åã§ããä¸è¨ã¯åã®MacBookã§ã®å®è¡çµæã§ãã $ python -c 'x=9007199254740991.0; print "%.19f\n%.19f" % (x, round(x))' 9007199254740991.0000000000000000000 9007199254740992.0000000000000â¦
ä»é±ã¯å½éæµ®åå°æ°ç¹æ°ã¦ã¤ã¼ã¯ã§ãã®ã§ãé±ã®æå¾ããã¯ãæµ®åå°æ°ç¹æ°ãã¿ã§ãã Rubyã®roundé¢æ°ã®å®è£ ã«é¢ãã¦ã1.8.6 patchlevel 114ã¨1.8.6 patchlevel 230ã®éã«å¤æ´ãå ¥ã£ã¦ãã¾ãã1.8.6-p230ã®ãªãªã¼ã¹ææã¯2008/06/20ã®ããã§ãããã1.8.7ï¼20â¦
PHPã®roundé¢æ°ã®ãªãã¡ã¬ã³ã¹ããã¥ã¢ã«ã®ãã¼ã¸ã«é¢ç½ãã³ã¡ã³ããè¦ã¤ããã®ã§ç´¹ä»ãã¾ãã
ãã¦ãå æ¥ã®è¨äºãPHP5.3.0alpha3ã®roundé¢æ°ã®å®è£ ãPHP5.2.6ã¨å¤ãã£ããã§ãç´¹ä»ããPHPã®roundé¢æ°ãæ¹åããææ¡ã«ã¯ãprintfã¨ã®æ´åæ§ã«ã¤ãã¦ãæ¸ããã¦ãã¾ããã¨ããã®ããprintfã§"%.2f"ãªã©ã¨ç²¾åº¦ãæå®ããå ´åãroundé¢æ°ã¨åæ§ã«ä¸¸ããçºçâ¦
é¡åã®éããPHP5.2.7ã§roundé¢æ°ã®å®è£ ãå¤æ´ããã¾ããã12æ8æ¥ä»ã§PHP5.2.8ããªãªã¼ã¹ããã¾ããããroundé¢æ°ã«ã¤ãã¦ã¯PHP5.2.7ã¨åä¸ã§ãã æ¦è¦ ã¾ãããããã®è¨äºã§æ¢å ±ã§ãããbugs #42294ã«é¢ãã¦PHP5.2.7ã§ä¿®æ£ãå ¥ããroundé¢æ°ã®å®è£ ãå¤ããâ¦
(2016/07/02 20:00追è¨)æ¬ç¨¿ãããã«æãä¸ããè¨äºãPHPã®roundé¢æ°ãèªã¿è§£ã (1)丸ãæ¡æ°ã大ãããã»å°ããããå ´åããPHPã®æ°ããroundé¢æ°ãèªã¿è§£ã (2)pre-roundingã®æå³ããæ¸ãã¾ãããåããã¦ã確èªãã ããã 12æ4æ¥ä»ã§PHP5.2.7ã¨PHP5.3.0aâ¦
iPhoneè²·ãè²·ãè¨ã£ã¦ãããã«çºå£²ããããå ¨ç¶è²·ããªã人ã£ã¦å± ã¾ãããããããåã®ãã¨ã§ããè²·ãè²·ãè©æ¬ºã§ããã ãããªãèå³ããããã ãç¡ããã ãããããªãiPhoneã§ããã©ããå¤ã®50é£çº!! ãããå®çªiPhoneã¢ããªã ï¼åç·¨ï¼ãã¨ããè¨äºãè¦ã¦ãâ¦
ã¤ãå ããroundã®è©±é¡ãèªã¿ç´ãã¦ã¿ã¾ãããèªåã§è¨ãã®ãã¢ã¬ã§ããä¸ã é¢ç½ãã§ããããã ãä»ã«ãªã£ã¦ã¿ãã¨ç¡é§ã«ã ãã«ãªã£ã¦ããèªåã«æ°ã¥ãã¾ãã ã©ããããã¨ãã¨ããã¨ãèªåã§ãæåã¯ãPHPã£ã¦ã¤ã«ãã¦ãã§ããããã¯ã¯ãã£ã¦ã¤ããã§æ¸ãã¦â¦
é¡åã®éããªãã§ãããååã®è¨äºãPHP以å¤å ¨å¡ä¸æ£è§£ãã«å¯¾ãã¦ããã¦ãï¼ããé æ´ããã®ã§ã¾ã¨ãã¦ã¿ã¾ãã Cã®ãã®åä½ããå¯ä¸ç¡äºçµ¶å¯¾ã®ãã®ã§ããã¨ããæ ¹æ ã¯ã©ãã«ããã®ã§ãããã? strtod ã«ããã°ã If the subject sequence has the decimal foâ¦
ãã¾ã ã«roundé¢æ°ã®ã¾ã¨ãã¯åºæ¥ã¦ãã¾ãããããããçæ§ã«å¿ããããåã«ã¾ã¨ããªãããªãã¨ã¯æã£ã¦ãã¾ããããããã°ãããå¾ ã¡ãã ãããä»åã¯å¾®å¦ã«roundé¢æ°ã¨è¿ããããªé ããããªè©±é¡ã§ãã 巨大ãªæ°ã®ä¸¸ãã«ã¤ãã¦å®é¨ãã¦ãããã¡ã«ãPHPã ãâ¦
å°ãªãã¨ãåæ°äººã¯å± ãã¨æãããèªè ã®çæ§ããã¶ãããã¦ããã¾ããããµããªã®ãããã¾ã¨ãè¨äºã¯å ¨ãæ¸ãã¦ãã¾ããã ãã¦ãä»åã¯ä»æã®è¨äºã®ç´¹ä»ã§ããPerlã®Math::Roundã¨ããã¢ã¸ã¥ã¼ã«ã«PHPã¨ä¼¼ããããªãã¸ãã¯ãã³ãã¼ãæ¡ç¨ããã¦ããããã§ãâ¦
ãã¦ãä»åã¯Rubyã¨Pythonã®é¡åãã¤ãã¦ãã¾ãã¾ãããã©ããããã®è¨èªã ãã«éããªããããªè©±é¡ã§ã*1ãæ©éã§ãããFreeBSDç°å¢ãç¨æãã¦ãã ããï¼ããããSPARC Solarisç°å¢ãMac OS Xç°å¢ã§ãåãçµæã ããã¨æãã¾ãããåã¯ç¢ºèªãã¦ãã¾ããï¼ã â¦
ããå æ¸ã¾ã¨ãããä»ã®è¨äºæ¸ããã£ã¦æãã§ãããã¾ã ã¾ã roundé¢æ°ã®ç¶ãã§ããå®éã®ã¨ããåãçµæ§é£½ãã¦ããããã¾ãã ãã®ä¸é£ã®roundé¢æ°ã®ä»¶ã«ã¤ãã¦è¨åãã¦ããè¨äºãè¦ãã¨ãããªãæªããç¥èã¬ãã«ã®äººãããããã«æãã¾ãããããªè¨äºããã¡â¦
Refererä¸è¦§ã®åå¨ã«æ°ã¥ããã®ã§ããªã³ã¯ãã¦ä¸ãã£ã¦ããæ¹ã ã®æç« ãä»æ´èªãã§ãã¾ãããã ãããããæµ®åå°æ°ç¹æ°ã®æ±ããæãã®ãroundé¢æ°ã®ããã«ãã¦ãããããªæç« ãè¦ã¤ãã¾ããããããããã誤解ãããã°é常ã«æ®å¿µã ã¨æãã¨åæã«ãããã ãâ¦
ãã¦ãã¾ãã¾ããPHPã®å¥å¦ãªroundé¢æ°ãã®ç¶ãã§ããä»åã¯ã¿ã¤ãã«ãããããªãè² ãããã§ããã©ãæ°ã«ããããã¾ãããã Matzããã®è¨äºã«åè«ããã«ã¯ããªãçè«æ¦è£ ãå¿ è¦ã ããã¨ããèãããããã2åã®è¨äºã¯åã¨ãã¦ãé å¼µã£ã¦æ¸ãã¦ãã¾ããããâ¦