Calculator
"9"){ return false } } return true } function
DontChange(){ CalculateValue() } // rounds inputVal to
specified decimal places function RoundValue(inputVal,
decPlaces){ //...add (or subtract) just enough of the value
to handle the truncation later... inputVal =
parseFloat(inputVal) if (inputVal >= 0){ inputVal =
inputVal + (5 * Math.pow(10, -(decPlaces+1))) } else{
inputVal = inputVal - (5 * Math.pow(10, -(decPlaces+1))) }
inputStr = "" + inputVal outputStr = ""
isDecimal = false exponentFound = false for (var i = 0; i
< inputStr.length; i++){ var oneChar =
inputStr.charAt(i) //... if a decimal has been already
found, decrement the counter if (isDecimal) --decPlaces; //
...if decimal point located, set flag, and exit with value
if no decimal places are needed if (oneChar ==
'.'){ isDecimal = true if (decPlaces == 0){
continue } } // ...add the character if necessary if
((oneChar == 'E') || (oneChar == 'e') ||
(oneChar == 'D') || (oneChar == 'd')) {
exponentFound = true } // ...Add character if necessary if
(exponentFound || decPlaces >= 0) { outputStr =
outputStr + oneChar } } return outputStr } // End Script
-->