bigatom.e

bigatom.e

Note:

This is a modified bigatom.e file

  • some creole formatting added
  • cut and paste Google Translation added

Copyright (C) 2014 Carlos G?mez Andreu (cargoan)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.


bigatom.e

por Carlos J. G?mez Andreu (cargoan)

Mis n?meros en coma flotante en base 10.

La funci?n log() y relacionadas est?n adaptadas de bigfixedmath.e (Lucius L. Hilley III) del Archivo de Euphoria. M?s precisa que la interna de euphoria y la que mejor ha ido con bigatoms.

La funci?n exp() adaptada de las manpages de bc.

La funci?n euler(), sobre el algoritmo no tengo ni idea, sacada de un ejemplo en Modula-2 de un viejo compilador de Modula-Oberon que, muuucho tiempo ha, utilizaba en OS/2 llamado XDS. El algoritmo original fu? escrito en Algol por Serge Batalov, reescrito en Modula-2 y modificado por Eugene Nalimov y Pavel Zemtsov. Adaptado a Euphoria por m? (sin l?mite de decimales).

Un bigatom es una sequence de tres elementos, el signo, el exponente y la mantisa. El signo es 1 si el n?mero es positivo, -1 si es negativo ? 0 si es cero.

El valor de un bigatom se eval?a en la forma: valor = signo * mantisa * 10^exponente El punto decimal va impl?cito tras el primer d?gito de la mantisa.

Un mismo valor puede tener diferentes representaciones. ej. el n?mero -23.456 quedar?a representado as?:

       { -1, 1, {2, 3, 4, 5, 6} } = -1 * 2.3456 * 10^1 

o as?:

       { -1, 3, {0, 0, 2, 3, 4, 5, 6} } = -1 * 0.023456 * 10^3 

tambi?n as?:

       { -1, 1, {2, 3, 4, 5, 6, 0, 0} } = -1 * 2.345600 * 10^1 

etc.

Reduci?ndose siempre a la forma m?s corta y almacenando ?nicamente los d?gitos significativos del n?mero; eliminando los ceros a derecha e izquierda hasta el primer d?gito distinto de cero y ajustando el exponente en consecuencia.

La funci?n normalize() es la encargada de realizar esta tarea.

Comments:

by Carlos J. G?mez Andreu (cargoan)

My floating point numbers in base 10.

The log() function and related are adapted bigfixedmath.e (Lucius L. Hilley III) - Archive of Euphoria.

More accurate than the internal of euphoria and it went better with bigatoms.

The exp() function adapted from the manpages of bc.

Euler function () on the algorithm I have no idea, taken from an example in Modula-2 of an old Modula-Oberon compiler that has a looooong time, used in OS / 2 called XDS.

The original algorithm was written in Algol by Serge Batalov, rewritten in Modula-2 and modified by Eugene Nalimov and Pavel Zemtsov.

Adapted Euphoria by me (unlimited decimals).

A bigatom is a sequence of three elements, the sign, the exponent and mantissa.

The sign is 1 if the number is positive, -1 if negative or 0 if zero.

The value of a bigatom is evaluated in the form:

value = sign * mantissa * 10 ^ exponent 

The decimal point is implied after the first digit of the mantissa.

The same value can have different representations.

eg. the number 23456 would be represented as follows: 
<eucode> 
{ -1, 1, {2, 3, 4, 5, 6} } = -1 * 2.3456 * 10^1 

or so

{ -1, 3, {0, 0, 2, 3, 4, 5, 6} } = -1 * 0.023456 * 10^3 
</eucod> 
also like: 
<eucode> 
{ -1, 1, {2, 3, 4, 5, 6, 0, 0} } = -1 * 2.345600 * 10^1 

Always reduced to the shortest way and storing only the significant digit number; removing zeros left and right to - First nonzero digit and adjusting the exponent accordingly.

The normalize () function is responsible for this task.


part2

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu