# Algorithm for rounding to n decimal places

lewws shared this question 2 years ago

Hi,

we know 15 decimal places is limit of precision within Geogebra.

However can anyone assist to use some algorithm using Geogebra scripts or Javascript inside Geogebra to convert a rational number p/q to say n decimal places where n can go up to 200?

Example from external site at mathisfun :

https://www.mathsisfun.com/...

1

Hi.

To do what you are looking for Geogebra should provide some devoted instrinsic functions, like the ones below related to the well known package MatLab, or its Octave clone (free of charge).

Normally MatLab works around 15-digit precision, which can be expanded to the desired one through the funnction vpa() of symbolic calculation.

Cheers

2

You can use the CASView, eg Numeric(1/7,200)

1

Thanks, Michael!

1

Fantastic!

1

@chaffeur: Thanks for both your replies.

Btw, how do I transfer these values into a textbox in Graphics 1 or 2 panel?

1

Right click on the CAS cell number, then select Copy as Latex in the context menu, create a new Text and paste it there.

1

I have no idea, unfortunately. What I've done above has been carried out manually through my usual editor (geany) by separating the (pi) single-row along with the vertical green marker. Cheers

1

According to Simona Riva suggestion

1

Dynamic Reference:

1

The problem is: how to split down one row into several lines in i.e. 72 columns? Now, Geogebra doesn't do it.

1

I have no solution for that... as i can not extract the displayed text programmatically. For other strings there could be done something like there.

1

Thanks, -Loco-and @chaffeur perhaps using list commands and a bit of hard coding thing can work (add algorithm to make this work) see attached.

1

Hi Simona,

Thanks for your contribution of ideas too to copy the Latex.

Am also exploring if I could use the JavaScript Geogebra commands to copy (SetValue) over...

1

One more idea!

1

Thanks again!

Geogebra used to allow for python scripts...Hope it can be incoeporated again in one way or another in the future...

1

Another way - drag the red point:

https://www.geogebra.org/m/UipIJcvQ

1

Michael,

Brilliant! Something the younger students can easily see!Thanks!

1

So fine, Noel! Thanks a lot