#CJam, <strike>35</strike> 27 bytes ri{_e-3_i}g;1mOo]," kMG"='B Thanks Dennis for removing 8 bytes. This doesn't print `.0` in the [online interpreter](http://cjam.aditsu.net/#code=ri%7B_e-3_i%7Dg%3B1mOo%5D%2C%22%20kMG%22%3D'B&input=1149999). But as [Dennis has pointed out](https://codegolf.stackexchange.com/questions/51928/format-the-given-number-of-bytes-to-a-human-readable-format/51936#comment123505_51939), it works fine in the Java interpreter. ###Explanation ri e# Read the input as an integer. { e# Do: _e-3 e# Make a copy and divide by 1000. e# This will generate one more item in the stack for each iteration. _i e# Make a copy and truncate to integer. }g e# until the integer part is 0. ; e# Discard the final value with integer part 0. 1mOo e# Output the number before it with the correct format. ], e# Count the number of iterations - 1. " kMG"= e# Select a character according to the number of iterations. 'B e# Output B.