Algorithm for rounding to n decimal places

lewws shared this question 1 year ago
Answered

Hi,

From numerous threads, eg.

https://help.geogebra.org/topic/inaccuracy-probem-internal-15-decimals-is-not-enough

https://help.geogebra.org/topic/decimal-precision-question

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/...

Comments (18)

photo
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

98887881a2108f114623d79220d48291

photo
2

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

photo
1

Thanks, Michael!

photo
photo
1

Fantastic!

bce30f7ad56f17a5552abd02487f096b

photo
1

@chaffeur: Thanks for both your replies.


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

photo
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.

photo
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

photo
1

According to Simona Riva suggestion

54194b5f61bb19ff34aa5a3bc33913ca

photo
1

Dynamic Reference:

/AZrY33zcovZCAAAAAElFTkSuQmCC

photo
1

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

photo
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.

photo
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.

photo
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...

photo
photo
1

One more idea!

28a0c5f0d2ff7dc847485f8db231dd29

photo
1

Thanks again!

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

photo
photo
1

Another way - drag the red point:


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

photo
1

Michael,

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

photo
photo
1

So fine, Noel! Thanks a lot

d9e1ec1cba834315c87d73452dd46714

© 2020 International GeoGebra Institute