Lo que todo programador debería saber sobre aritmética de punto flotante
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Traducidas cheat sheets de los lenguajes

+213 -168
+1 -1
content/errors/comparison.html
··· 87 87 Esto es conceptualmente muy evidente y fácil y tiene la ventaja de que escala 88 88 implícitamente el margen de error relativo con la magnitud de los valores. 89 89 Técnicamente es un poco más complejo, pero no mucho más de lo que puedas pensar, 90 - porque los números del IEEE 754 están diseñados para mantener su orden cuando 90 + porque los números de punto flotante del IEEE 754 están diseñados para mantener su orden cuando 91 91 sus secuencias de bits se interpretan como enteros. 92 92 93 93 Sin embargo, este método requiere que el lenguaje de programación soporte conversión
+1 -1
content/errors/rounding.html
··· 41 41 se incrementa el último dígito. Este método es el que se enseña en el colegio normalmente 42 42 y es el que usa la mayoría de la gente. Minimiza el error, pero también introduce un sesgo 43 43 (lejos del cero). 44 - * **Redondeo la mitad al par** también conocido como el **redondeo del banquero** - si la 44 + * **Redondeo mitad al par** también conocido como el **redondeo del banquero** - si la 45 45 fracción truncada es mayor que la mitad de la base, se incrementa el último dígito. 46 46 Si es igual a la mitad de la base, se incrementa solamente si el resultado es par. Esto 47 47 minimiza el error y el sesgo, y por eso se prefiere en contabilidad. Es el método por
+20 -20
content/languages/csharp.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for C# 3 - description: Tips for using floating-point and decimal numbers in C# 2 + title: Cheat sheet de punto flotante para C# 3 + description: Trucos para usar punto flotante y números decimales en C# 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - C# has [IEEE 754](/formats/fp/) single and double precision types supported by keywords: 6 + Tipos de punto flotante 7 + ----------------------- 9 8 10 - float f = 0.1f; // 32 bit float, note f suffix 11 - double d = 0.1d; // 64 bit float, suffix optional 9 + C# tiene tipos de precisión sencilla y doble del [IEEE 754](/formats/fp/) 10 + soportados por palabras clave: 12 11 12 + float f = 0.1f; // punto flotante de 32 bits, nótese el sufijo f 13 + double d = 0.1d; // punto flotante de 64 bits, sufijo opcional 13 14 14 - Decimal Types 15 - ------------- 16 - C# has a 128 bit [limited-precision](/formats/exact/) decimal type denoted by the keyword 17 - <code>decimal</code>: 15 + Tipos decimales 16 + --------------- 18 17 19 - decimal myMoney = 300.1m; // note m suffix on the literal 18 + C# tiene un tipo decimal de 128 bit de [precisión limitada](/formats/exact/) 19 + denotado con la palabra clave `decimal`: 20 20 21 + decimal myMoney = 300.1m; // Nótese el sufijo m en el literal 21 22 22 - How to Round 23 - ------------ 24 - The <code>Math.Round()</code> method works with the double and decimal types, and allows you to specify a [rounding mode](/errors/rounding/): 23 + Cómo redondear 24 + -------------- 25 25 26 - Math.Round(1.25m, 1, MidpointRounding.AwayFromZero); // returns 1.3 26 + El método `Math.Round()` funciona con los tipos `double` y `decimal`, 27 + y permite especificar el [método de redondeo](/errors/rounding/): 27 28 29 + Math.Round(1.25m, 1, MidpointRounding.AwayFromZero); // Devuelve 1.3 28 30 31 + Recursos 32 + -------- 29 33 30 - Resources 31 - --------- 32 34 * [C# Reference](http://msdn.microsoft.com/en-us/library/618ayhy6%28v=VS.80%29.aspx) 33 35 * [float type](http://msdn.microsoft.com/en-us/library/b1e65aza%28v=VS.80%29.aspx) 34 36 * [double type](http://msdn.microsoft.com/en-us/library/678hzkk9%28v=VS.80%29.aspx) 35 37 * [decimal type](http://msdn.microsoft.com/en-us/library/364x0z75%28v=VS.80%29.aspx) 36 38 * [Math.Round()](http://msdn.microsoft.com/en-US/library/system.math.round%28v=VS.80%29.aspx) 37 - 38 -
+41 -33
content/languages/java.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for Java 3 - description: Tips for using floating-point and decimal numbers in Java 2 + title: Cheat sheet de punto flotante para Java 3 + description: Trucos para usar punto flotante y números decimales en Java 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - Java has [IEEE 754](/formats/fp/) single and double precision types supported by keywords: 6 + Tipos de punto flotante 7 + ----------------------- 8 + 9 + Java tiene tipos de precisión sencilla y doble del [IEEE 754](/formats/fp/) soportados 10 + por palabras clave: 11 + 12 + float f = 0.1f; // punto flotante de 32 bits, nótese el sufijo f 13 + double d = 0.1d; // punto flotante de 64 bits, sufijo opcional 14 + 15 + La palabra clave `strictfp` en las clases, interfaces y métodos fuerza también 16 + a que todos los resultados intermedios de cálculos en punto flotante sean 17 + valores IEEE 754, garantizando resultados idénticos en todas las plataformas. 18 + Sin esa palabra clave, las implementaciones pueden usar un rango extendido para 19 + el exponente, llevando a resultados más precisos y ejecuciones más rápidas 20 + en bastantes CPUs. 9 21 10 - float f = 0.1f; // 32 bit float, note f suffix 11 - double d = 0.1d; // 64 bit float, suffix optional 12 - 13 - The `strictfp` keyword on classes, interfaces and methods forces all intermediate results of floating-point calculations to be IEEE 754 values as well, guaranteeing identical results on all platforms. Without that keyword, implementations can use an extended exponent range where available, resulting in more precise results and faster execution on many common CPUs. 14 - 15 - Decimal Types 16 - ------------- 17 - Java has an [arbitrary-precision](/formats/exact/) decimal type named <code>java.math.BigDecimal</code>, which 18 - also allows to choose the [rounding mode](/errors/rounding/). 22 + Tipos decimales 23 + --------------- 24 + 25 + Java tiene un tipo decimal de [precisión arbitraria](/formats/exact/) llamado 26 + `java.math.BigDecimal`, que también permite elegir el [método de redondeo](/errors/rounding/). 19 27 20 28 BigDecimal a = new BigDecimal("0.1"); 21 29 BigDecimal b = new BigDecimal("0.2"); 22 - BigDecimal c = a.add(b); // returns a BigDecimal representing exactly 0.3 30 + BigDecimal c = a.add(b); // Devuelve un BigDecimal que representa exactamente 0.3 23 31 32 + Cómo redondear 33 + -------------- 34 + 35 + Para obtener una cadena: 24 36 25 - How to Round 26 - ------------ 27 - To get a String: 37 + String.format("%.2f", 1.2399) // Devuelve "1.24" 38 + String.format("%.3f", 1.2399) // Devuelve "1.240" 39 + String.format("%.2f", 1.2) // Devuelve "1.20" 40 + 41 + Para imprimir por la salida estándar (o cualquier `PrintStream`): 42 + 43 + System.out.printf("%.2f", 1.2399) // Misma sintaxis que String.format() 28 44 29 - String.format("%.2f", 1.2399) // returns "1.24" 30 - String.format("%.3f", 1.2399) // returns "1.240" 31 - String.format("%.2f", 1.2) // returns "1.20" 32 - 33 - To print to standard output (or any <code>PrintStream</code>): 45 + Si no quieres ceros a la derecha: 34 46 35 - System.out.printf("%.2f", 1.2399) // same syntax as String.format() 36 - 37 - If you don't want trailing zeroes: 47 + new DecimalFormat("0.00").format(1.2)// Devuelve "1.20" 48 + new DecimalFormat("0.##").format(1.2)// Devuelve "1.2" 38 49 39 - new DecimalFormat("0.00").format(1.2)// returns "1.20" 40 - new DecimalFormat("0.##").format(1.2)// returns "1.2" 41 - 42 - If you need a specific [rounding mode](/errors/rounding/): 50 + Si necesitas un [método de redondeo](/errors/rounding/) específico: 43 51 44 - new BigDecimal("1.25").setScale(1, RoundingMode.HALF_EVEN); // returns 1.2 52 + new BigDecimal("1.25").setScale(1, RoundingMode.HALF_EVEN); // Devuelve 1.2 45 53 54 + Recursos 55 + -------- 46 56 47 - Resources 48 - --------- 49 57 * [Java Language Specification](http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html) 50 58 * [Floating-Point Types, Formats, and Values](http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3) 51 59 * [Java Standard API](http://java.sun.com/javase/6/docs/api/)
+21 -19
content/languages/javascript.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for JavaScript 3 - description: Tips for using floating-point and decimal numbers in JavaScript 2 + title: Cheat sheet de punto flotante para JavaScript 3 + description: Trucos para usar punto flotante y números decimales en JavaScript 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - JavaScript is dynamically typed and will often convert implicitly between strings and floating-point numbers (which are IEEE 64 bit values). To force a variable to floating-point, use the global <code>parseFloat()</code> function. 6 + Tipos de punto flotante 7 + ----------------------- 8 + 9 + JavaScript tiene tipado dinámico y a veces convertirá implícitamente entre cadenas 10 + y números de punto flotante (que son valores IEEE de 64 bits). Para forzar una variable 11 + a punto flotante, utiliza la función `parseFloat()`. 9 12 10 13 var num = parseFloat("3.5"); 11 14 12 - Decimal Types 13 - ------------- 15 + Tipos decimales 16 + --------------- 14 17 15 - The best decimal type for JavaScript seems to be a port of [Java's](/languages/java/) <code>BigDecimal</code> class, which also supports [rounding modes](/errors/rounding/): 18 + El mejor tipo decimal para JavaScript parece ser una migración de la clase de 19 + [Java](/languages/java/) `BigDecimal`, que también soporta [métodos de redondeo](/errors/rounding/): 16 20 17 21 var a = new BigDecimal("0.01"); 18 22 var b = new BigDecimal("0.02"); 19 23 var c = a.add(b); // 0.03 20 24 var d = c.setScale(1, BigDecimal.prototype.ROUND_HALF_UP); 21 25 22 - 23 - How to Round 24 - ------------ 26 + Cómo redondear 27 + -------------- 25 28 26 29 var num = 5.123456; 27 - num.toPrecision(1) //returns 5 as string 28 - num.toPrecision(2) //returns 5.1 as string 29 - num.toPrecision(4) //returns 5.123 as string 30 - 31 - Using a specific rounding mode: 30 + num.toPrecision(1) //Devuelve 5 como una cadena 31 + num.toPrecision(2) //Devuelve 5.1 como una cadena 32 + num.toPrecision(4) //Devuelve 5.123 como una cadena 33 + 34 + Utilizando un método de redondeo específico: 32 35 33 36 new BigDecimal("1.25").setScale(1, BigDecimal.prototype.ROUND_HALF_UP); 34 37 38 + Recursos 39 + -------- 35 40 36 - Resources 37 - --------- 38 41 * [BigDecimal for JavaScript](https://github.com/dtrebbien/BigDecimal.js) 39 42 * [Core JavaScript Reference](https://developer.mozilla.org/en/JavaScript/Reference) 40 43 * [parseFloat()](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/parseFloat) 41 44 * [toPrecision()](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Number/toPrecision) 42 -
+46 -34
content/languages/perl.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for Perl 3 - description: Tips for using floating-point and decimal numbers in Perl 2 + title: Cheat sheet de punto flotante para Perl 3 + description: Trucos para usar punto flotante y números decimales en Perl 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - Perl supports platform-native floating-point as scalar values; in practice this usually means [IEEE 754](/formats/fp/) double precision. 6 + Tipos de punto flotante 7 + ----------------------- 9 8 10 - Exact Types 9 + Perl soporta números de punto flotante nativos de la plataforma como valores 10 + escalares; en la práctica esto significa precisión doble del [IEEE 754](/formats/fp/). 11 + 12 + Tipos exactos 11 13 ------------- 12 - Perl can also store decimal numbers as strings, but the builtin arithmetic operators will convert them to integer or floating-point values to perform the operation. 13 14 14 - The <code>Math::BigFloat</code> extension provides an arbitrary-precision [decimal type](/formats/exact/): 15 + Perl también puede almacenar números decimales como cadenas, pero los operadores 16 + aritméticos integrados los convertirán a enteros o a valores de punto flotante 17 + para realizar la operación. 18 + 19 + La extensión `Math::BigFloat` proporciona un [tipo decimal](/formats/exact/) de 20 + precisión arbitraria: 15 21 16 22 use Math::BigFloat ':constant' 17 - my $f = 0.1 + 0.2; # returns exactly 0.3 18 - 19 - The <code>Number::Fraction</code> extension provides a fraction type that overloads the arithmetic operators with [symbolic](/formats/exact/) fraction arithmetic: 23 + my $f = 0.1 + 0.2; # Devuelve exactamente 0.3 24 + 25 + La extensión `Number::Fraction` proporciona un tipo de datos fraccionario que 26 + sobrecarga los operadores con aritmética [simbólica](/formats/exact/) para fracciones: 20 27 21 28 use Number::Fraction ':constants'; 22 - my $f = '1/2' - '1/3'; # returns 1/6 23 - 24 - The <code>Math::BigRat</code> extension provides similar functionality. Its advantage is compatibility with the 25 - <code>Math::BigInt</code> and <code>Math::BigFloat</code> extensions, but it does not seem to support fraction literals. 29 + my $f = '1/2' - '1/3'; # Devuelve 1/6 26 30 27 - How to Round 28 - ------------ 29 - To get a string: 31 + La extensión `Math::BigRat` proporciona funcionalidad similar. Su ventaja es 32 + compatibilidad con las extensiones `Math::BigInt` y `Math::BigFloat`, pero 33 + no parece soportar literales fraccionarios. 30 34 31 - $result = sprintf("%.2f", 1.2345); # returns 1.23 32 - 33 - To format output: 35 + Cómo redondear 36 + -------------- 34 37 35 - printf("%.2f", 1.2); # prints 1.20 36 - 37 - Note that this implicitly uses [round-to-even](/errors/rounding/). The variable <code>$#</code> contains the default format for printing numbers, but its use is considered deprecated. 38 + Para obtener una cadena: 38 39 39 - The <code>Math::Round</code> extension provides various functions for rounding floating-point values: 40 + $result = sprintf("%.2f", 1.2345); # Devuelve 1.23 41 + 42 + Para formatear la salida: 43 + 44 + printf("%.2f", 1.2); # Imprime 1.20 45 + 46 + Ten en cuenta que esto utiliza implícitamente [mitad al par](/errors/rounding/). 47 + La variable `$#` contiene el formato por defecto para imprimir números, pero 48 + su uso se considera obsoleto. 49 + 50 + La extensión `Math::Round` proporciona varias funciones para redondear valores 51 + de punto flotante: 40 52 41 53 use Math::Round qw(:all); 42 - $result = nearest(.1, 4.567) # prints 4.6 43 - $result = nearest(.01, 4.567) # prints 4.57 44 - 45 - The <code>Math::BigFloat</code> extension also supports various [rounding modes](/errors/rounding/): 54 + $result = nearest(.1, 4.567) # Imprime 4.6 55 + $result = nearest(.01, 4.567) # Imprime 4.57 56 + 57 + La extensión `Math::BigFloat` también soporta varios [métodos de redondeo](/errors/rounding/): 46 58 47 59 use Math::BigFloat; 48 60 my $n = Math::BigFloat->new(123.455); 49 - my $f1 = $n->round('','-2','common'); # returns 123.46 50 - my $f2 = $n->round('','-2','zero'); # returns 123.45 61 + my $f1 = $n->round('','-2','common'); # Devuelve 123.46 62 + my $f2 = $n->round('','-2','zero'); # Devuelve 123.45 63 + 64 + Recursos 65 + -------- 51 66 52 - Resources 53 - --------- 54 67 * [Semantics of numbers and numeric operations in Perl](http://perldoc.perl.org/perlnumber.html) 55 68 * [sprintf function](http://perldoc.perl.org/functions/sprintf.html) 56 69 * [Math::Round extension](http://search.cpan.org/dist/Math-Round/Round.pm) 57 70 * [Number::Fraction extension](http://search.cpan.org/~davecross/Number-Fraction-1.13/lib/Number/Fraction.pm) 58 71 * [Math::BigRat extension](http://search.cpan.org/~flora/Math-BigRat-0.26/lib/Math/BigRat.pm) 59 72 * [Math::BigFloat extension](http://search.cpan.org/~flora/Math-BigInt-1.95/lib/Math/BigFloat.pm) 60 -
+21 -16
content/languages/php.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for PHP 3 - description: Tips for using floating-point and decimal numbers in PHP 2 + title: Cheat sheet de punto flotante para PHP 3 + description: Trucos para usar punto flotante y números decimales en PHP 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - PHP is dynamically typed and will often convert implicitly between strings and floating-point numbers (which are platform-dependant, but typically IEEE 64 bit values). To force a value to floating-point, evaluate it in a numerical context: 6 + Tipos de punto flotante 7 + ----------------------- 8 + 9 + PHP tiene tipado dinámico y a veces convertirá implícitamente entre cadenas y 10 + números de punto flotante (que son dependientes de la plataforma, pero normalmente 11 + valores IEEE de 64 bits). Para forzar un valor a punto flotante, evalúalo en un 12 + contexto numérico: 9 13 10 14 $foo = 0 + "10.5"; 11 15 16 + Tipos decimales 17 + --------------- 12 18 13 - Decimal Types 14 - ------------- 15 - The BC Math extension implements [arbitrary-precision](/formats/exact/) decimal math: 19 + La extensión BCMath (Binary Calculator) implementa aritmética de [precisión 20 + arbitraria](/formats/exact/) decimal: 16 21 17 22 $a = '0.1'; 18 23 $b = '0.2'; 19 - echo bcadd($a, $b); // prints 0.3 24 + echo bcadd($a, $b); // Imprime 0.3 20 25 21 - How to Round 22 - ------------ 23 - Rounding can be done with the `number_format()` function: 26 + Cómo redondear 27 + -------------- 28 + 29 + Redondear se puede hacer con la función `number_format()`: 24 30 25 31 $number = 4.123; 26 - echo number_format($number, 2); // prints 4.12 32 + echo number_format($number, 2); // Imprime 4.12 27 33 34 + Recursos 35 + -------- 28 36 29 - Resources 30 - --------- 31 37 * [PHP manual](http://www.php.net/manual/en/index.php) 32 38 * [Floating point types](http://www.php.net/manual/en/language.types.float.php) 33 39 * [BC Math extension](http://de3.php.net/manual/en/ref.bc.php) 34 40 * [number_format()](http://de3.php.net/manual/en/function.number-format.php) 35 -
+34 -23
content/languages/python.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for Python 3 - description: Tips for using floating-point and decimal numbers in Python 2 + title: Cheat sheet de punto flotante para Python 3 + description: Trucos para usar punto flotante y números decimales en Python 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - Almost all platforms map Python floats to [IEEE 754](/formats/fp/) 9 - double precision. 6 + Tipos de punto flotante 7 + ----------------------- 8 + 9 + Casi todas las plataformas asocian los `float` de Python a números de punto 10 + flotante de doble precisión del [IEEE 754](/formats/fp/). 10 11 11 12 f = 0.1 12 13 13 - Decimal Types 14 - ------------- 15 - Python has an [arbitrary-precision](/formats/exact/) decimal type named <code>Decimal</code> in the <code>decimal</code> module, which also allows to choose the [rounding mode](/errors/rounding/). 14 + Tipos decimales 15 + --------------- 16 + 17 + Python tiene un tipo de [precision arbitraria](/formats/exact/) decimal llamado 18 + `Decimal` en el módulo `decimal`, que también permite elegir el [método de 19 + redondeo](/errors/rounding/). 16 20 17 21 a = Decimal('0.1') 18 22 b = Decimal('0.2') 19 - c = a + b # returns a Decimal representing exactly 0.3 23 + c = a + b # Devuelve un Decimal que representa exactamente 0.3 24 + 25 + Cómo redondear 26 + -------------- 27 + 28 + Para obtener una cadena: 29 + 30 + "{:.2f}".format(1.2399) # Devuelve "1.24" 31 + "{:.3f}".format(1.2399) # Devuelve "1.240" 32 + "{:.2f}".format(1.2) # Devuelve "1.20" 20 33 21 - How to Round 22 - ------------ 23 - To get a string: 34 + Para imprimir por la salida estándar (Python 2.x): 24 35 25 - "%.2f" % 1.2399 # returns "1.24" 26 - "%.3f" % 1.2399 # returns "1.240" 27 - "%.2f" % 1.2 # returns "1.20" 28 - 29 - To print to standard output: 36 + print "{:.2f}".format(1.2399) 30 37 31 - print "%.2f" % 1.2399 # just use print and string formatting 32 - 33 - Specific [rounding modes](/errors/rounding/) and other parameters can be defined in a Context object: 38 + y en Python 3.x: 39 + 40 + print("{:.2f}".format(1.2399)) 41 + 42 + [Métodos de redondeo](/errors/rounding/) específicos y otros parámetros se pueden 43 + definir enun objeto `Context`: 34 44 35 45 getcontext().prec = 7 36 46 37 - Resources 38 - --------- 47 + Recursos 48 + -------- 49 + 39 50 * [Floating Point Arithmetic: Issues and Limitations](http://docs.python.org/tutorial/floatingpoint.html) 40 51 * [The decimal module](http://docs.python.org/library/decimal.html) 41 52 * [Context objects](http://docs.python.org/library/decimal.html#context-objects)
+28 -21
content/languages/sql.html
··· 1 1 --- 2 - title: Floating-point cheat sheet for SQL 3 - description: Tips for using floating-point and decimal numbers in SQL 2 + title: Cheat sheet de punto flotante para SQL 3 + description: Trucos para usar punto flotante y números decimales en SQL 4 4 --- 5 5 6 - Floating-Point Types 7 - -------- 8 - The SQL standard defines three binary floating-point types: 6 + Tipos de punto flotante 7 + ----------------------- 8 + 9 + El estándar SQL define tres tipos de punto flotante binarios: 10 + 11 + * `REAL` tiene precisión dependiente de la implementación (normalmente se asocia a un tipo a nivel de hardware como precisión sencilla o doble del IEEE 754). 12 + * `DOUBLE PRECISION` tiene precisión dependiente de la implementación que es mayor que la de `REAL` (normalmente se asocia al precisión doble del IEEE 754). 13 + * `FLOAT(N)` tiene al menos `N` dígitos binarios de precisión, con un máximo para `N` que depende de la implementación. 9 14 10 - * `REAL` has implementation-dependant precision (usually maps to a hardware-supported type like IEEE 754 single or double precision) 11 - * `DOUBLE PRECISION` has implementation-dependant precision which is greater than `REAL` (usually maps to IEEE 754 double precision) 12 - * `FLOAT(N)` has at least `N` binary digits of precision, with an implementation-dependant maximum for `N` 15 + El rango del exponente para los tres tipos también depende de la implementación. 13 16 14 - The exponent range for all three types is implementation-dependant as well. 17 + Tipos decimales 18 + --------------- 15 19 16 - Decimal Types 17 - ------------- 18 - The standard defines two fixed-point decimal types: 20 + El estándar define dos tipos decimales de punto fijo: 19 21 20 - * `NUMERIC(M,N)` has exactly `M` total digits, `N` of them after the decimal point 21 - * `DECIMAL(M,N)` is the same as `NUMERIC(M,N)`, except that it is allowed to have more than `M` total digits 22 + * `NUMERIC(M,N)` tiene exactamente `M` dígitos en total, `N` de los cuales después del punto decimal. 23 + * `DECIMAL(M,N)` es lo mismo que `NUMERIC(M,N)`, excepto porque permite tener más de `M` dígitos totales. 22 24 23 - The maximum values of `M` and `M` are implementation-dependant. Vendors often implement the two types identically. 25 + Los valores máximos de `M` y `N` dependen de la implementación. Los proveedores 26 + normalmente implementan los dos tipos de manera idéntica. 24 27 25 - How to Round 26 - ------------ 28 + Cómo redondear 29 + -------------- 27 30 28 - The SQL standard defines no explicit rounding, but most vendors provide a `ROUND()` or `TRUNC()` function. 31 + El estándar SQL no define explícitamente el redondeo, pero la mayoría de los 32 + proveedores proporciona una función `ROUND()` o `TRUNC()`. 29 33 30 - However, it usually makes little sense to round within the database, since its job is *storing* data, while rounding is an aspect of *displaying* data, and should therefore be done by the code in the presentation layer. 34 + Sin embargo, normalmente no tiene mucho sentido redondear dentro de la base de 35 + datos, puesto que su función es *almacenar* los datos, mientras que redondear 36 + es un aspecto de la *representación* de los datos, y debe por tanto hacerse 37 + en el código de la capa de presentación. 31 38 39 + Recursos 40 + -------- 32 41 33 - Resources 34 - --------- 35 42 * [Official ISO SQL 2008 standard (non-free)](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=38640) 36 43 * [SQL 92 draft (free)](http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt) 37 44 * [MySQL numeric types](http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html)