Wednesday, 16 September 2015

Scientific Notation To Decimal Converter Code



-----------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE IN POST HTML SECTION
------------------------------------------------------------------------------------------------------------------


<html>
<head>


<title>Scientific Notation To Decimal Converter</title>

<script language="JavaScript">
function perRound(num, precision) {
var precision = 3;
precision = parseInt(precision);
var result1 = num * Math.pow(10, precision);
var result2 = Math.round(result1);
var result3 = result2 / Math.pow(10, precision);
return zerosPad(result3, precision);
}
function zerosPad(rndVal, decPlaces) {
var valStrg = rndVal.toString();
var decLoc = valStrg.indexOf(".");
if (decLoc == -1) {
decPartLen = 0;
valStrg += decPlaces > 0 ? "." : "";
}
else {
decPartLen = valStrg.length - decLoc - 1;
}
var totalPad = decPlaces - decPartLen;
if (totalPad > 0) {
for (var cntrVal = 1; cntrVal <= totalPad; cntrVal++)
valStrg += "0";
}
return valStrg;
}
function clear_field(field) {
if (field.value==field.defaultValue) {
field.value='';
}
}
function DefaultVal(){
var mantissa=Math.random()*9+1;
mantissa=0.001*Math.round(1000*mantissa);
var exponent=Math.random()*8;
exponent=Math.floor(exponent);
var sign=Math.random()*2-1;
if(sign<0) exponent*=-1;
document.convertform.mantissa.value=mantissa;
document.convertform.exponent.value=exponent;
document.convertform.corans.value=0;
}
function ClearVal(){
var mantissa = 0;
var exponent = 0;
document.convertform.mantissa.value=mantissa;
document.convertform.exponent.value=exponent;
document.convertform.corans.value=0;
}
function Convert(){
var CorrectAnswer=parseFloat(document.convertform.mantissa.value)*Math.pow(10,parseFloat(document.convertform.exponent.value));
document.convertform.corans.value=CorrectAnswer;
}

</script>

</head>

<BODY>
<meta name="viewport" content="width=958, initial-scale=1">
<tr><td colspan="3"><br />
</td></tr>
</table></div>
<table ALIGN="center" width="950" BORDER=0 CELLPADDING=5>
<tr BGCOLOR=#FFFFFF>
<td WIDTH=80%>
<h1>Scientific Notation To Decimal Converter</h1>
<tr BGCOLOR=#B6D4D2>
<br><br>
<form name="convertform">
<center>
<tr BGCOLOR=#FFFFFF valign="top">
<table align="center" BORDER=5 CELLPADDING=5>
<tr BGCOLOR=#B6D4D2>
<td align="center" colspan="2">
Scientific Notation Required Data Entry
</tr>
<tr>
<td>
Convert The Number
<input type="text" size="18" value="0" name="mantissa"> (mantissa) x 10^
</td>
<td>
<input type="text" size="10" value="0" name="exponent"> (exponent)
</td>
</tr>
<tr>
<td colspan="2" align="center" BGCOLOR=#B6D4D2>
<input type="button" name="check" value="Convert" onClick="Convert()">&nbsp;&nbsp;&nbsp;
<input type="button" name="new" value="Assign Random Default Values" onClick="DefaultVal()">&nbsp;&nbsp;&nbsp;
<input type="Reset" value="Clear Values" onClick="ClearVal()">
<br />
<hr style="background:#ffd148;border:0;height:5px" />
<hr style="background:#ffd148;border:0;height:5px" />
</td>
</tr>
<tr BGCOLOR=#B6D4D2>
<td align="center" colspan="2">
Calculated Decimal Results
</td>
</tr>
<tr>
<td>
The Decimal Equivalent Is
</td>
<td>
<input type="text" size="18" value="0" name="corans" readonly>
</td>
</td></tr>
</form>
</tr></table>
<BR><BR>
</BODY>
</HTML>




0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

FB Gadgets | Template Designed by Fatakat PhotosCoolBThemes.com
Code by : paid web directory

https://www.google.co.uk/search?q=site%3Ablogspot.com+fbgadgets