Convert double precision number to rational fraction plus exponent

467 Views Asked by At

I have a double precision quantity (either pixels per cm or pixels per inch) that gets converted into pixels per meter. I then need to convert this number into a rational fraction, with numerator and denominator as unsigned shorts, and exponent of signed byte.

I realize this is an ill-posed problem, but I am looking for the best way of doing this conversion.

Thanks.