RESPONDER UNA PREGUNTA

Si para responder la pregunta, crees necesario enviar un archivo adjunto, puedes hacerlo a traves del correo [email protected]

    Pregunta:  17116 - REDONDEO
Autor:  Octava
Quisiera redondear número grandes como: 8.47457627118644
Pero no obtengo el resultado que deseo, ¿alguién me podría ayudar?

Utilizo esta función, cuyos parametros son: nombre del text y el nro de decimales a redondear.

function RedondeoDecimal(fieldName, decAllowed) {
fieldValue=FilterNum(fieldName.value);
if (isNaN(fieldValue) || fieldValue == "") {
fieldName.value=""
} else {
if (fieldValue.indexOf('.') == -1) fieldValue += ".";
dectext=fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);
if (dectext.length > decAllowed) {
dectext="1" + dectext;
for (i=1;i<=decAllowed;i++) {
dectext=Math.round(parseFloat(dectext) / 10);
}
sDec=dectext.toString(10);
sDec=sDec.substring(1,sDec.length);
if (sDec.length>decAllowed) {
sDec=sDec.substring(0,decAllowed);
}
while (sDec.length < decAllowed) {
sDec=sDec + "0";
}
fieldValue=fieldValue.substring(0,fieldValue.indexOf('.')+1)+sDec;
fieldName.value=fieldValue;
} else {
while (dectext.length < decAllowed) {
fieldValue=fieldValue + "0";
dectext=fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);
}
fieldName.value=fieldValue;
}
}
}

Gracias.


Nombre
Apellidos
Correo
Comentarios