Perl 114 111 104 chars
My first ever code-golf entry!
Arguments provided from standard input: perl fna.pl 918395 1
($n,$d)=@ARGV;
@n=$n=~/./g;
@s=' kMGTPE'=~/./g;
printf"%.".(@n>3?$d:0)."f%s",$n/(10**($#n-$#n%3)),$s[@n/3];
Output:
918.4k
De-golfed version (with explanation):
( $number, $dp ) = @ARGV; # Read in arguments from standard input
@digits = split //, $number; # Populate array of digits, use this to count
# how many digits are present
@suffix = split //, ' kMGTPE'; # Generate suffix array
$number/(10**($#n-$#n%3)); # Divide number by highest multiple of 3
$precision = @n>3 ? $dp : 0; # Determine number of decimal points to print
sprintf "%.".$precision."f%s", # "%.2f" prints to 2 dp, "%.0f" prints integer
$number, $suffix[@n/3];# Select appropriate suffix