## Perl program for rounding down less than 100 yen

Let's create a Perl program that rounds down less than 100 yen. This is useful when you want to round off the tax amount of less than 100 yen after multiplying by the tax rate.

Suppose the first amount given is "198,223 yen". Let's round down less than 100 yen to "198,200 yen".

### How to truncate less than 100 yen?

The process of truncating less than 100 yen is considered as follows.

- Divide by 100
- Truncate the decimals
- Multiply by 100

use strict; use warnings; # Amount of money my $price = 198_223; # Divide by 100 (1982.23) my $price_div = $price / 100; # Extract the integer part (1982) my $price_div_cut = int $price_div; # Multiply 100 (198,200) my $price_cut = $price_div_cut * 100; # Output result print "$price_cut\n";

Four arithmetic operations and extracting the integer part int function.

You can copy and paste this program and try it immediately at PerlBanjo.