4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

perlで切り捨て処理

Last updated at Posted at 2022-04-05

小数点以下の切り捨てをperlで実現したかったが
int関数でうまくいかなかった

perl -e '$v=int(110/1.1);print $v;'
99

100にならない。。

なので別のアプローチをして対処。
(.をデリミタにしてsplitする作戦)

perl -e '$v=110/1.1;($v)=split /\./,$v; print $v;'
100

正攻法なのだろうか。。

4
2
9

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?