Hello Tom, What if N and D have different lengths? Catapulté de mon aPhone
Le 19 nov. 2015 à 19:47, Tom Rokicki <rokicki@gmail.com> a écrit :
Why not just interleave digits (bits if base 2), and say numerator is first?
So 1/2 becomes just 12. 113/355 is 131535.
1/1000 is 001/1000 is 1000010.
123/1 is 102031.
-tom
On Thu, Nov 19, 2015 at 10:30 AM, Eric Angelini <Eric.Angelini@kntv.be> wrote:
Hello Math-Funsters,
I was looking for a way to represent any fraction with one single integer. Do you know if there is a common way to do that or a paper about it? I came up with this (heavy?) idea: concatenate N and D and encode the place of the slash "/".
So, the fraction we want to represent is N/D. We build the integer NDBA with four concatenated strings of digits. Starting from the right:
A is a single digit B is a string that has length A (if A=0 then A=10) D is the denominator of the fraction N/D N is the numerator of the fraction N/D
To reconstruct the fraction N/D from NDBA we:
- read A - compute the length of B - read B - insert the symbol "/" after B digits, starting the count from the leftmost digit of NDBA - erase A and B
Examples:
The fraction 1/2 --> 1211 [or 12.1.1 --> 1/2] The fraction 113/355 --> 11335531 [113/355.3.1] The fraction 2015/1234567890 --> 2015123456789041 [2015/1234567890.4.1] The fraction 1234567890/888 --> 1234567890888102 [1234567890888.10.2] etc.
This system works for N having less than 10 billion digits, of course -- which seems ok in our everyday life (we would have an integer like ND.9999999999.0 with ten 9's)
Best, É.
P.-S. Many integers will not represent any fraction -- but this is another story (10211 would produce the fraction 1/02, for instance).
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
-- -- http://cube20.org/ -- [ <http://golly.sf.net/>Golly link suppressed; ask me why] -- _______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun