cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Translate the entire conversation x

convert from decimals to fractions

pannus0
10-Marble

convert from decimals to fractions

Is there a function to convert from decimals to fractions?

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:pannus0)


@pannus0 wrote:

Is there a function to convert from decimals to fractions?


Not ready-made. You would have to program your own.

In real Mathcad (legacy Mathcad, versions 15 and below) there was a formatting option which would display a number with fractions but Prime does not offer this facility.

View solution in original post

9 REPLIES 9
LucMeekes
23-Emerald IV
(To:pannus0)

Try the symbolic keyword confrac.

 

Success!
Luc

I tried it as you suggested and I get:

 

pannus0_1-1762281018387.png

 

LucMeekes
23-Emerald IV
(To:pannus0)

That's correct, it means 0 + 1/2.

Did you read the manual? Add ",fraction" to confrac and see what happens.

 

Success!
Luc

Werner_E
25-Diamond I
(To:LucMeekes)

Werner_E_0-1762282839434.png

Definitely fractions, but chances are that @pannus0  expected to see 13 + 9/20 🙂

Werner_E
25-Diamond I
(To:pannus0)


@pannus0 wrote:

Is there a function to convert from decimals to fractions?


Not ready-made. You would have to program your own.

In real Mathcad (legacy Mathcad, versions 15 and below) there was a formatting option which would display a number with fractions but Prime does not offer this facility.

LucMeekes
23-Emerald IV
(To:Werner_E)

In real mathcad we had (have !):

LucMeekes_0-1762281496349.png

and the functionality is available in Prime as well, according to the manual.

 

Luc

Something curious only happens with 0.25,0.25, but when they are numbers for example 0.375 this doesn't happen, any solution?

 

 

pannus0_0-1762282870965.png

 

 

Werner_E
25-Diamond I
(To:LucMeekes)


@LucMeekes wrote:

In real mathcad we had (have !):

LucMeekes_0-1762281496349.png

and the functionality is available in Prime as well, according to the manual.

 

Luc


Really? Can you post a link to the corresponding help page in Mathcad Prime Help

 

I could not find "convert" in Prime and also not in legacy Mathcad 15.

Neither as a function nor as a symbolic keyword.

And "confrac" with modifier "fraction" works the same in Prime as in MC15

Werner_E_0-1762284674197.png

 

Werner_E
25-Diamond I
(To:pannus0)

Here is a quick hack. The display is all but nice, though.

Werner_E_1-1762285303760.png

It should(may) work up to 12 decimals. Using a higher value for N increases the chance for round off errors when using "gcd".

We could determine the power of 10 needed to multiply the number to get an integer using strings. We might convert the absolute value of the fractional part into a string, delete the leading zero and the decimal point (if present) and the length of the string would correspond to the exponent of the power of 10 needed. Nonetheless the main problem still is the ugly display of the result.

 

In case you are not looking for mixed fractions you may also use the similar "test2".

Werner_E_2-1762285412809.png

While the display format as an 1x3 or 1x2 matrix sure isn't clear an nice, we have at least numerical results which could be used for further calculations (whatever they may be).

Of course we could convert the result into a string which makes for a slightly nicer look but could be used for display only.

Werner_E_3-1762285844645.png

 

Best result in Prime I could achieve was with the symbolical evaluation of a simple program

Werner_E_4-1762285907582.png

 

But sure nothing compares with the simplicity of real Mathcad's formatting options:

Werner_E_0-1762356544099.png

 

Prime 11 sheet attached

 

 

Announcements

Top Tags