Yggdrasil is completely right, but I find personally enah's way is easier to understand. When I've taught people about converting, I usually teach them using the way enahs posted (multiply by a fraction and cancel out units).
Nater11, if you aren't sure about how to convert something in the future try doing things the way enahs did it. The fraction is simply a conversion factor. In this case 1g = 1000mg. You want to convert to g so you need mg on the bottom to cancel out. Therefore you need to use
( 1g )
1000mg like enahs did.