in reply to Stupid sprintf question - decimals
#!/usr/bin/perl use strict; use warnings; printf "%.2f%s", "4212412124124124.10623", "\n"; printf "%.2f%s", "12412124124124.10623", "\n";
outputs the result
4212412124124124.00 12412124124124.11
You are exceeding machine precision on your decimal. See What Every Computer Scientist Should Know About Floating-Point Arithmetic for background.
|
|---|