Mega Code Archive

 
Categories / Perl / String
 

Using precision while printing floating-point numbers

#!usr/bin/perl use warnings; use strict; my $float = 123.94536; printf "\t%.3f\n\t%.3e\n\t%.3g\n\n", $float, $float, $float;