Código PHP:
eso es un extracto de mi planilla...Ver original
<?php function exp_to_dec($float_str) // formats a floating point number string in decimal notation, supports signed floats, also supports non-standard formatting e.g. 0.2e+2 for 20 // e.g. '1.6E+6' to '1600000', '-4.566e-12' to '-0.000000000004566', '+34e+10' to '340000000000' // Author: Bob { // make sure its a standard php float string (i.e. change 0.2e+2 to 20) // php will automatically format floats decimally if they are within a certain range $float_str = (string)((float)($float_str)); // if there is an E in the float string { // get either side of the E, e.g. 1.6E+6 => exp E+6, num 1.6 // strip off num sign, if there is one, and leave it off if its + (not required) else $num_sign = ''; if($num_sign === '+') $num_sign = ''; // strip off exponential sign ('+' or '-' as in 'E+6') if there is one, otherwise throw error, e.g. E+6 => '+' else trigger_error("Could not convert exponential notation to decimal notation: invalid float string '$float_str'", E_USER_ERROR); // get the number of decimal places to the right of the decimal point (or 0 if there is no dec point), e.g., 1.6 => 1 // get the number of decimal places to the left of the decimal point (or the length of the entire num if there is no dec point), e.g. 1.6 => 1 // work out number of zeros from exp, exp sign and dec places, e.g. exp 6, exp sign +, dec places 1 => num zeros 5 if($exp_sign === '+') $num_zeros = $exp - $right_dec_places; else $num_zeros = $exp - $left_dec_places; // build a string with $num_zeros zeros, e.g. '0' 5 times => '00000' // strip decimal from num, e.g. 1.6 => 16 // if positive exponent, return like 1600000 if($exp_sign === '+') return $num_sign.$num.$zeros; // if negative exponent, return like 0.0000016 else return $num_sign.'0.'.$zeros.$num; } // otherwise, assume already in decimal notation and return else return $float_str; } ?> <?php { $en_menos_con_seg_ob = $_POST['en_menos_con_seg_ob'] * 3.80; } ?> <style type="text/css"> <!-- .Estilo5 {font-size: 12px} --> </style> <form name="form1" method="post" action=""> <table width="90" height="41" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center" class="Estilo5">3.80</div> <label> <input name="en_menos_con_seg_ob" type="text" id="en_menos_con_seg_ob" style="text-align:center" size="10"/> </label></td> </tr> </table> <table width="146" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="176" height="48"><div align="center"> </div></td> </tr> </table> <p> <label> <input type="submit" name="valor" id="valor" value="Enviar"> </label> </p> </form>
lo mas raro, q al poner 999.65 en el textbox, me devuelve 3798.67. Eso esta perfecto, pero en la planilla entera me devuelve 3798.7, osea redondea. No quiero que redondee!