用户工具

站点工具


linux:perl:perl向上取整
Writing /share/Web/wiki/data/cache/a/a26ac212d150806d632bb720e2dd7988.xhtml failed

1. 利用POSIX模块处理 向下/向上取整

use POSIX;
 
POSIX::ceil(3.14) => 4   #向上取整
 
POSIX::floor(3.14) => 3   # 向下取整, 等同于 int(3.14)

2. 利用Math::Round 做四舍五入

use Math::Round;
 
my $num = 45.4;
 
my $round = Math::Round($num);
linux/perl/perl向上取整.txt · 最后更改: 2023/03/17 10:12 由 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki