Formatted numeric output: Difference between revisions
Content added Content deleted
(→{{header|J}}: delete irrelevant example) |
(added ocaml and c++) |
||
Line 27:
{
printf ("%08d", val); // Prints 8 digits with leading zeros
}
=={{header|C++}}==
#include <iostream>
#include <iomanip>
int main()
{
std::cout << std::setfill('0') << std::setw(9) << std::fixed << std::setprecision(3) << 7.125;
}
Line 76 ⟶ 86:
//or, put in browser URL: javascript:n=123;alert(("00000"+n).slice(-5));
=={{header|OCaml}}==
Printf.printf "%09.3f" 7.125
=={{header|Perl}}==
|