I am almost certain that there is no simple function. The simple method is as I described. Decide upon a precision threshold, and check the digits to the right of the decimal place. There is a method to truncate into an integer, so you can make two strings and concatenate them. so your 8/3 as 2.333333 becomes 2 and 1/3.

The reason is that .3333333333333333333 is not 1/3. It is an approximation of 1/3, and to go between the two needs some human judgement, e.g. IF statements.

Computers don't use that notation as they usually deal in decimals. Fractions are just our way of simplifying how we read it. So I doubt there is a "simple" way, but someone may have written a javascript library to handle that type of thing for some type of math learning app. So you may be ale to find one and write a plugin for it. But C2 most likely doesn't have a built in easy way as that isn't really a common gaming requirement.

Above example is just what i want.but it has some restricts:

it can process 1 recursive digit such as .3333..., but cannot process 2 or more recursive digit (maybe 6 is enough). for example: 0.142857142857...->1/7 ,0.076923076923...->1/13, which has 6 recursive digit. It also need skip leading digit that may not be recursive, e.g. 0.4777?->43/90 ,that leading 4 is not recursive.

Maybe more work needed ,it's not a simple task anyway .

Yann's "DecimalToFraction" is really very useful for me . maybe it could be put plugin to enhance maths function.