師匠の散歩

きままにPerlでも

Floor関数

モジュールによる床関数や丸め関数を確認する/ subFloorRound.cgi

POSIXモジュール

use POSIX;my $minus = -0.34 ; my $plus = 8.1; print "floor( $minus )= .floor($minus);"print "floor( $plus )= .floor($plus);"print "ceil( $minus )= .ceil($minus);"print "ceil( $plus )= .ceil($plus);"
floor( -3.4 )=-4floor( 8.1 )=8ceil( -3.4 )=-3ceil( 8.1 )=9

Math::Roundモジュール

残念ながら、本サーバーで Math::Round は使用できなかった

use Math::Round;
my $data=-3.9;
print "round( $data ) =";
print round($data);
Can't locate Math/Round.pm in /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . (/usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . contains: /usr/local/lib/perl5/5.10.1/BSDPAN /usr/local/lib/perl5/site_perl/5.10.1/mach /usr/local/lib/perl5/site_perl/5.10.1 /usr/local/lib/perl5/5.10.1/mach /usr/local/lib/perl5/5.10.1 .) at test.cgi line 12,  line 855.
BEGIN failed--compilation aborted at test.cgi line 12,  line 855.

subFloorRound.cgi // Topに戻る // indexに戻る
Copyright(C) 2009-2021 Grandmaster Last up : 2020/09/18