「定数PHP_ROUND_FUZZは0.50000000001なんていう不思議な数に定義されているみたいですよ!こんな見事なマジックナンバーは久々に見ました!」と、下記のブログにありました。
PHPの奇妙なround関数
http://d.hatena.ne.jp/hnw/20070515
が、ためしにGoogleで“0.50000000001”と検索すると、結構出てきます。この数。
あと、この方、
http://bugs.php.net/bug.php?id=24142
に気がついておられますが、rasmusあっとphp.netさん(PHPの前身を世に送り出した人)の"round to even"、"banker's rounding"に関するコメントをすっ飛ばしているように思いますが、いいのかなぁ。
"This is expected behaviour. When rounding on exact halves we round down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even. If you want to learn more, search the web for terms such as "round to even" or "banker's rounding" and you will find that most languages actually do it this way."
日本語で「四捨五入する関数」といったら挙動は間違いになりますが、英語では「丸める関数」(round)です。
下記を見ると、「丸め」方は一通りでないことが書いてあります。PHPにも触れていますね。
http://en.wikipedia.org/wiki/Rounding
What Every Computer Scientist Should Know About Floating-Point Arithmetic
http://docs.sun.com/source/806-3568/ncg_goldberg.html
ちょっとInterrop関連の準備で忙しいのであまり勉強できていないんですが、もう少し突っ込んで調べると面白そうです。カナダブースにいらしても、この話は、なしにしましょう!(笑)
追記:
hnwさんも触れておられますが、
下記のコメント欄には時系列で記録が残っていますね。
http://jp.php.net/manual/ja/function.round.php
ラベル:PHP_ROUND_FUZZ
丸めの種類はたくさんあるよ、というお話が突然出てきたように見えますけど、CPUが丸めモードを切り替えられることだとしたらここでは無関係ですよね。PHPのroundはマニュアルの通りの四捨五入です。0.00000000001くらいオマケがつくこともありますけど。この部分、何か僕が勘違いしていますかね?
0.50000000001で検索したら、というのは僕はやっていなかったので少し面白かったですけど、少なくともこの数の数学的根拠が議論されているようなものは無さそうですね。何か面白そうなものがあったら教えてもらえると嬉しいです。
では、お暇になったらお付き合いくださいませ :-)
I recently came across a post you made last year (http://douzo.seesaa.net/article/28809659.html) about fixing the mm_menu.js file in Dreamweaver to include iframes for the dropdown menus. Your solution worked wonderfully, and my dropdown menus work perfectly in Internet Explorer now. However, I was wondering if it was possible to also have the iframes work in Firefox?? Any input or advice you have would be very helpful---thank you!