Mine
public text v1 · immutable#!/bin/bash
#interex@deathtrip.org / #Linux @ DALnet
input1=$1
output1=`echo "$input1 /1024" | bc -l `
output2=`echo "$input1 /1024 /1024 " | bc -l `
output3=`echo "$input1 /1024 /1024 /1024 " | bc -l `
echo $output1 kilobytes
echo $output2 megabytes
echo $output3 gigabytes
-----
Perl:
sub round {
my ($n, $places) = @_;
my $factor = 10 ** ($places || 0);
return int(($n * $factor) + ($n < 0 ? -1 : 1) * 0.5) / $factor;
}
round(123.123,2) --> 123.12