td>
| td>
| td>
| td>
| td>
TR>
TABLE>
TABLE>
B>
Form>
Center>
VAR fkeypad = document.forms ['keypad'];
VAR Accum = "0";
Var flagnewnum = false;
Var pendingop = "";
/ / =========================================================================================================================================================================================== ========================================= // [Description] Floating point number precision calculation // [parameter] str1 - the first one Number // str2 - second number // type - operator // Precision - Digital accuracy // [Call mode] longcount (str1, str2, type, precision; // [Return value] calculation results // = ============================================================================================================================================================================================================= ============================ function longcount (str1, str2, type) {var COMMA1 = 0; if (str1.indexof ")! = - 1) {str1 = str1.replace; comma1 = str1.length - str1.indexof (". ") - 1;} var COMMA2 = 0; IF Str2.indexof (".")! = - 1) {str2 = str2.replace (/ 0 * $ /, "); comMA2 = str2.length - str2.indexof (". ") - 1;} str1 = Str1.replace (//./, ""); str2 = str2.replace (//./, ""); var value, comma; if (Type! = "*") {if (COMMA1> COMMA2) { For (var i = 0; i
} else {for (VAR i = 0; I 0) value = value.substring (0, value.length-comma) "." Value.substring (Value. Length-comma, value.length; if (value.indexof (".")! = - 1) value = value.Replace (/ 0 * $ /, ""); return value;} function NumpRessed (NUM) { IF (FLAGNEWNUM) {fkeypad.readout.value = Num; flagnewnum = false;} else {if (fkeypad.readout.value == "0") fkeypad.readOut.Value = Num; else fkeypad.readOut.valu E = Num;}} function operation (op) {var readout = fkeypad.readout.value; if (Flagnewnum && pendingop! = "="); else {flagnewnum = true; if (' ' == pendingop || '/' == pendingop || '*' == pendingop) accum = longcount (account, readout, pendingop); else accum = readout; fkeypad.readOut.Value = Accum; pendingop = op FKeyPad.ReadOut.focus ();
转载请注明原文地址:https://www.9cbs.com/read-106816.html
|