Perl Format Decimal 2 Places Not Rounding

[Solved] Perl Format Decimal 2 Places Not Rounding | Perl - Code Explorer | yomemimo.com
Question : perl format decimal 2 places not rounding

Answered by : outstanding-oystercatcher-2ngdyb4ddvfx

my $places = 2;
my $factor = 10**$places;
int(1.555 * $factor) / $factor; # 1.55

Source : https://stackoverflow.com/questions/35043874/how-can-i-format-a-number-to-2-decimal-places-in-perl | Last Update : Wed, 01 Jul 20

Answers related to perl format decimal 2 places not rounding

Code Explorer Popular Question For Perl