Format 1234.56789 : sprintf « String « Perl






Format 1234.56789

   
print sprintf "%.4f\n", $value;
print sprintf "%.5f\n", $value;
print sprintf "%6.6f\n", $value;
print sprintf "%+.4e\n", $value;

   
    
    
  








Related examples in the same category

1.Adding float-point number to the result returning from sprintf function
2.Converting digit to string with sprintf
3.Format Options for sprintf and printf
4.Format and sprintf
5.The sprintf command returns a formatted string
6.Using sprintf to format a float-point number and assign the result to a variable
7.Using sprintf.
8.print sprintf "%+.4e\n", $value;
9.print sprintf "%.2f", 3.1415926;
10.print sprintf "%6.6f\n", $value;
11.sprintf function assigns the formatted string to a variable.
12.sprintf function with array variable