exponential growth problem with showing 19 digits

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

martingz
Posts: 401
Joined: Wed Nov 18, 2009 11:14 pm
Location: Mexico

Re: exponential growth problem with showing 19 digits

Post by martingz »

It could be that it only shows 19 and rounds the last
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: exponential growth problem with showing 19 digits

Post by Claudio Ricardo »

Hi... I thing but not sure, Harbour use IEEE 754 Math standard inherited from Clipper.
https://en.wikipedia.org/wiki/IEEE_754

The solution would be to divide into two words, multiply the least significant (right) first, add the carry digit to the second (left),
multiply it and then concatenate the results in a string. cResult := "left_result" + "right_result"
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: exponential growth problem with showing 19 digits

Post by SALINETAS24 »

ROBROS wrote: Tue Dec 22, 2020 7:09 pm Hi friends,
surely most of you if not all know the story of the grains of rice on a chessboard. On the first field you put one grain, on the second field the first field is doubled, on the third field the second field is doubled and so on up to field 64. I have written a small program to demonstrate every step in this calculation. It works fine, but on the 64th field the result is unexpected: the 6 most right digits should be "775808" but it turns out they are :"776000".
I don't know why that happens. 19 digits should be possible, the number on field 63 also has 19 digits, which are shown exactly.

I have attached a zip file with all files necessary and a screenshot. I use the 32 bit version of hmg as you can see on the screenshot. Would a 64 bit version show the complete right 19 digits? Who can explain?

Thx Robert
Hola Robert.., Harbour es un fiel heredero de la arquitectura del CLIPPER 5.x y algunas de las carateristicas que presentaba el Clipper en su día eran las siguientes .....

Code: Select all

1 - Nº. máximo de registros por base de datos, 1000.000.000
2 - Nº. máximo de caracteres por registro, RAM disponible
3 - Nº. máximo de campos por registro, RAM disponible
4 - Nº. máximo de caracteres por campo, 32 kb
5 - Nº. de dígitos de precisión en operaciones de cálculo, 18
6 - Nº. máximo de caracteres en una clave de indexación, 250
7 - Nº. máximo de variables de memoria, 2048
8 - Tamaño máximo de una variable de memoria, 64 kb
9 - Nº. máximo de dígitos en una variable numérica, 19
10 - Nº. máximo de tablas, 2048
El punto 5 y el punto 19 te indican las limitaciones del lenguaje.
Ademas debes tener en cuenta que el signo (+ o -) también cuenta y está presente en la longitud.

https://elguille.info/clipper/manual.htm

Salud para todos y vamos con una cervecita bien fresquita !!!
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: exponential growth problem with showing 19 digits

Post by ROBROS »

Hi,
50 years ago I was taught Latin at school, so I know, that cervecita bien fresquita means fresh beer. Born and brought up in Bavaria I bid you and all forum members a "Prost" what origins from the Latin Prosit.
Thank you for explaining the limitations of clipper. My demonstration of exponential growth is an exception, I'm sure I never again will handle such big numbers.

Robert
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: exponential growth problem with showing 19 digits

Post by SALINETAS24 »

Buenos días, aquí tienes la solución para realizar el calculo. Ahora podemos jugar a contar los granos de trigo hasta mas allá del cuadro 64. Hasta el infinito y más allaaaaa!! :lol: Lo siento.

Vamos con una ronda virtual de cerveza fresquita.., que esta la pago yo.!! ;)
Attachments
ajedres.rar
(2.63 MiB) Downloaded 94 times
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: exponential growth problem with showing 19 digits

Post by Claudio Ricardo »

Exacto... Así hacía cuando programaba microcontroladores de 8 bits en assembler
para manejar cifras mayores a 255 (por eso puse arriba lo de dividir en 2 words)
Gracias por la cervecita virtual ! no imaginás el calor que hace acá. :P

Exactly ... This is how I did when programming 8-bit microcontrollers in assembler
to handle figures greater than 255 (that's why I put the divide into 2 words above)
Thanks for the virtual beer ! You cannot imagine how hot it is here. :P
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: exponential growth problem with showing 19 digits

Post by ROBROS »

Claudio wrote: cifras mayores a 255

"cifras": in German we use the word "Ziffer" :-)

Bottoms up and cheers!
Post Reply