HP Forums

Full Version: Print out a Fraction in textbook style
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

Im new to the HP Prime and im new to the Programming of this calculator.
But im not new to programming at all.

I have played around a bit and find the ability to do own stuff really nice.
Unfortunatley i have not figured out, how to print nice looking fractions out on the terminal.

Could somenone explain me how to write a fraction as an example:

2/7

with this style:

2
--
7

Keep in mind, im talking about the PRINT, or any other, Output function for own apps.

Thank you.
The Prime terminal does not support pretty-printing.
So if you want a fraction to appear on the terminal its
PRINT(NUM+"/"+DEN)
Or
LF="\n"
SEPRSIZE=MAX(DIM(STRING(NUM)),DIM(STRING(DEN))
SEPR= "-" repeated SEPRSIZE times (TBD)
PRINT(NUM+LF+SEPR+LF+DEN)

If it doesn't have to be on the terminal, you could try writing it as a Note, which allows more formatting.
Thank you for your answer.

The Background behind my question is, that i want to programm an quadratic equation solver.

This solver should output x1, x2 the discriminant and the vertex of the function.
For the vertex i would like to have the equation in the form of:

(x+y)^2-z

I would like to show the y part as a fraction and the z part also if possible.
Therefore i think its not that easy to use your suggestion.

The best way would be to just return the answer. But then i only can return one answer or some coma seperated values which doesnt look very good.
Here is an example.
Reference URL's