How do I write a quotient number exact without approximate value?

please how to write a quotient number axact without approximate value
example: I want to write 22/7 instead of 3.142 and thanks a lot

Is it that you want to return the result as a fraction rather than the decimal.
:thinking: This can be tricky
If all the steps for the calculation of result are know, then it might be done (maybe)
I don't know how my casio (calculator) does it? It even formats surds and pi.

Maybe just like this:
blocks - 2021-03-29T200000.471

Use the text JOIN block with 3 sockets, '/' in the middle.

Unless you want to use it in math. Then you can do this procedure.

In the text box, you enter the fraction in the form 22/7. For further calculations, you get a decimal with as many decimal places as you want.

Here is a little known AI2 feature ...

It has a rational number type, where it keeps the numerator and denominator behind the scenes. Here is proof ...
procedures_callreturn

rational data type proof

I stumbled on this when I long ago uncovered a bug (long since fixed) in TinyDB's ability to store the result of an integer division like 22/7, and Hal Abelson explained it.

P.S. The Scheme reference ...
https://groups.csail.mit.edu/mac/ftpdir/scheme-7.4/doc-html/scheme_5.html

2 Likes

Going back to the original question, if you lost track of the numerator and denominator of the division, AI2 does not have blocks for extracting them from the resulting exact fractional number.

You might get lucky by trying all the integers 2,3,4,5,... as possible denominators and seeing if multiplying by one of them gives you an exact integer result. But there is no limit to how far you would have to go to find the denominator.