in reply to Dividing and format
Here is an example:
The result isuse strict; while ( <DATA> ) { my $val = sprintf( "%.01f", $_/1000 ); # do maths with the truncated result.... my $val2 = $val * 2; print "$val - $val2\n"; } __DATA__ 100 1000 2314 171 123456789
0.1 - 0.2 1.0 - 2 2.3 - 4.6 0.2 - 0.4 123456.8 - 246913.6Note how the .0 is lost if you do any maths on 1.0 unless you format it again before printing - the first column is made of strings, the second of floats.
|
|---|