Retroceder   Foros del Web > Programación para sitios web > .NET

Respuesta
 
Herramientas Desplegado
Antiguo 21-may-2007, 10:12   #1 (permalink)
(Desactivado)
Developer9 Developer9
 
Avatar de Developer9
 
Fecha de Ingreso: abril-2005
Ubicación: Mi Ecuador del alma
Mensajes: 4.202
Enviar un mensaje por MSN a Developer9
Exclamación Lo que dice la ayuda sobre Redondear

Código:
Round Function
See Also
Int, Fix Functions

Requirements
Version 2 

Returns a number rounded to a specified number of decimal places.

Round(expression[, numdecimalplaces])
Arguments
expression 

Required. Numeric expression being rounded. 

numdecimalplaces 

Optional. Number indicating how many places to the right of the decimal are included in the rounding. If omitted, integers are returned by the Round function. 

Remarks
The Round function performs round to even, which is different from round to larger. The return value is the number closest to the value of expression, with the appropriate number of decimal places. If expression is exactly halfway between two possible rounded values, the function returns the possible rounded value whose rightmost digit is an even number. (In a round to larger function, a number that is halfway between two possible rounded values is always rounded to the larger number.)

Note   Round to even is a statistically more accurate rounding algorithm than round to larger.

Example
The following example uses the Round function to round a number to two decimal places: 

Dim MyVar, pi
pi = 3.14159
MyVar = Round(pi, 2) ' MyVar contains 3.14.
This example demonstrates how rounding to even works: 

Dim var1, var2, var3, var4, var5
var1 = Round(1.5)      ' var1 contains 2
var2 = Round(2.5)      ' var2 contains 2
var3 = Round(3.5)      ' var3 contains 4
var4 = Round(0.985, 2) ' var4 contains 0.98
var5 = Round(0.995, 2) ' var5 contains 1.00
el 0.985 no lo redondea a 0.99 pero el 0.995 si lo redondea a 1

entonces como hago para redondera 0.985 a 0.99?
Developer9 está desconectado   Responder Citando
Antiguo 22-may-2007, 04:58   #2 (permalink)
freegirl tiene algunos puntos positivos de karma
 
Avatar de freegirl
 
Fecha de Ingreso: octubre-2003
Ubicación: Catalunya
Mensajes: 2.292
Re: Lo que dice la ayuda sobre Redondear

Hola Developer9,


Prueba con FormatNumber.

Por ejemplo:

Cita:
FormatNumber (tuNumero,numDecimales)
Resultados:

12,344 --> 12,34
12,347 ---> 12,35
12,999 ---> 13,00
0,985 ---> 0,99

Saludos
freegirl está desconectado   Responder Citando
Antiguo 22-may-2007, 12:08   #3 (permalink)
(Desactivado)
Developer9 Developer9
 
Avatar de Developer9
 
Fecha de Ingreso: abril-2005
Ubicación: Mi Ecuador del alma
Mensajes: 4.202
Enviar un mensaje por MSN a Developer9
Re: Lo que dice la ayuda sobre Redondear

gracias amiga. Sos linda
Developer9 está desconectado   Responder Citando
Respuesta

No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 18:46.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93