Perlについての質問箱 21箱目
■ このスレッドは過去ログ倉庫に格納されています
0292ヽ(´ー`)ノ ◆.ogCuANUcE
2005/12/31(土) 00:44:38Q. Does Perl have a round() function? What about ceil() and floor()? Trig functions?
> Rounding in financial applications can have serious implications, and
> the rounding method used should be specified precisely. In these
> cases, it probably pays not to trust whichever system rounding is
> being used by Perl, but to instead implement the rounding function you
> need yourself.
(IEEE 754 的に)正しい結果が得られたかったら自前で実装するしかないようだ。
>>290
ということは、int($n + 0.5) ではなくて floor($n + .5) がいいんかね?
大人しく Math::Round::round() を使った方がいい気はする(笑)。
■ このスレッドは過去ログ倉庫に格納されています