View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
tf tf is offline
external usenet poster
 
Posts: 7
Default Extract numerator from fraction

Thanks all for your input.

I've been working with Niek's amended suggestion (though I had to replace
"right" with "left" to get the numerator instead of denominator). This
solution has worked for most of my values, but I have a few that are giving
me trouble.

Most of my fractions are four digit numerators with four digit denominators.
For those fractions with five digit numerators, the numerator that is
returned is missing the fifth digit. I've tried altering the number of
question marks in the formula, but have not had any luck.

Any further suggestions?

Here's an example:
The decimal "1.362162855" is formatted as the fraction "10757/7897" (using
custom formatting "####/####"; I've also tried altering this formatting to
get the correct numerator return). Using Niek's formula, the numerator
returned is "1075".

p.s. In response to Stephen, I actually need both numerator and denominator,
but once I figure out how to get one I can easily get the other, so for
simplicity didn't mention this. I do realize that the fraction is not the
exact representation of the decimal, but I think it is close enough for my
purposes, which are a little to complicated to go into!

"Bernd P" wrote:

Hello Niek,

I agree with you.

My suggestion is to use Oliver Aberth's algorithm, for example:
http://www.sulprobil.com/html/neares...al_number.html

Regards,
Bernd