This is not a trivial conversion. The problem, is that the starting point is a potential irrational number, so there won't be a clean conversion.
Here is a page on a Math site that explains the conversion process:
Here's another page that shows a table conversion:
It think the best strategy is a best match loop. Starting with the chunkier fractions first, then working down to finer grains until it's close enough.
Thom Parker - Software Developer at PDFScripting