Sunday, 13 September 2015
BINARY TO DECIMAL CODE


-----------------------------------------------------------------------------------------------------------------
COPY AND PASTE BELOW CODE IN POST HTML SECTION
------------------------------------------------------------------------------------------------------------------
<html>
<head>
<style type="text/css">
input { font-size: 1em; }
@media (max-width:799px) {
.btn { font-size: 1.2em; padding:7px; }
}
@media (min-width:800px) {
.btn { font-size: 1.2em; padding:4px; }
}
.intext {
background:url(data:image/gif;base64,R0lGODlhsQBfALMAAO+9jPe9iP+9e/+9hOLBnOnBnMbGwdbGs63G3rXG1r3GzrnG2qXG563G56XG75zG9ywAAAAAsQBfAAAE/lDISau9OOvNZQBgKI5BZ55oqq7s+QHEcRi0gtyMo+98z9wIBc0gI4AGraRyyex8YjbE7kGtWq/YbFb3SygORmRzTC5bPjObQ8tuu9+PnzBsrttPsIMazu/7q3JgAHeEdzAGCAx/i4x+DgwJBgQlhZUsATEJio2cnX0MXwCUlqQYAXoNa56rrG8OCJKjpZaYBg2tuLlvsAWzhQAHUrrDxFsJB4O+Y6cKqsXP0FSgBGLKl8HR2doPCdTWKcAI2+PZx7LfGAAGm+Tt0AgH5+gS6uzu98/w8sqn9vj/xbrNI5AAoMFoDhQkmxXAgLODEIkxODCrQMGIGJ8ptHTAX8aP/rgQECDU8CHIk60cUKxjEaXLYRvJdHxJM5fIMQ5r6ky5UomBnUBZqfQZtKinoSx+Gl3ayMFIFQdMMp0Kp8HTE1GpavVjFavUrWC1NOjFAYDHsGixJNhXQUHat216YjgAt24WBmQvmLXL18paDG77Cn4gdwKBwYMZLJxwEXHfwgC+Ok6LQJbSyXydTgggDnNfA4Y9C25A6bJou08Dn7a7svPquqAFuH79VoEAzrTrIhAQOTdcBh8k+57qAITw4UsV90YeFsGAvczBJpAwO/rU2KatM316WPtUxfTOetc5fUL18TtjS8iOvqaDvLzFtz9puwL7+SffW4CO32V9C/f1/heRfnrJJyBA/11A14EZ4bVBgAy6g5QGATQW4T/qbVDALRfiowBbFxBwXIfFILBYBwuSuI1mKkCoYi4TQjXii510lURWNOpioxIEcJgjKwnAx6OPP3KSwIlLtFRkIwaAmAQAqi3JhwMZ1kHAeVJmEaQl6sz440ROmkFQlljE5Es/ZD5w0zwFRJkjlUh+MyaNCQk5jwQDENBMh3XeqaECBloHip1+poPIfLDEWSiFenqJmQPdhLmoBgXYMlwDBhA6qQqYAHraNJJumkItqQyGqRGikkSAAZq8BWksqc5ySCLEBYFMNbFac4gmjv7zSCTIhJqrrAVAkUAivUqEgBeSLRSg6LC55pEGDsnC8cgNkRCBKrTcqgBAsTIMcSwQ5JaL7RDaOtvtuuy2O0EEAAA7);
font-family:'Comic Sans MS';
font-weight:bold;
}
.outtext {
background:url(data:image/gif;base64,R0lGODlhsQBfALMAAO+9jPe9iP+9e/+9hOLBnOnBnMbGwdbGs63G3rXG1r3GzrnG2qXG563G56XG75zG9ywAAAAAsQBfAAAE/lDISau9OOvNZQBgKI5BZ55oqq7s+QHEcRi0gtyMo+98z9wIBc0gI4AGraRyyex8YjbE7kGtWq/YbFb3SygORmRzTC5bPjObQ8tuu9+PnzBsrttPsIMazu/7q3JgAHeEdzAGCAx/i4x+DgwJBgQlhZUsATEJio2cnX0MXwCUlqQYAXoNa56rrG8OCJKjpZaYBg2tuLlvsAWzhQAHUrrDxFsJB4O+Y6cKqsXP0FSgBGLKl8HR2doPCdTWKcAI2+PZx7LfGAAGm+Tt0AgH5+gS6uzu98/w8sqn9vj/xbrNI5AAoMFoDhQkmxXAgLODEIkxODCrQMGIGJ8ptHTAX8aP/rgQECDU8CHIk60cUKxjEaXLYRvJdHxJM5fIMQ5r6ky5UomBnUBZqfQZtKinoSx+Gl3ayMFIFQdMMp0Kp8HTE1GpavVjFavUrWC1NOjFAYDHsGixJNhXQUHat216YjgAt24WBmQvmLXL18paDG77Cn4gdwKBwYMZLJxwEXHfwgC+Ok6LQJbSyXydTgggDnNfA4Y9C25A6bJou08Dn7a7svPquqAFuH79VoEAzrTrIhAQOTdcBh8k+57qAITw4UsV90YeFsGAvczBJpAwO/rU2KatM316WPtUxfTOetc5fUL18TtjS8iOvqaDvLzFtz9puwL7+SffW4CO32V9C/f1/heRfnrJJyBA/11A14EZ4bVBgAy6g5QGATQW4T/qbVDALRfiowBbFxBwXIfFILBYBwuSuI1mKkCoYi4TQjXii510lURWNOpioxIEcJgjKwnAx6OPP3KSwIlLtFRkIwaAmAQAqi3JhwMZ1kHAeVJmEaQl6sz440ROmkFQlljE5Es/ZD5w0zwFRJkjlUh+MyaNCQk5jwQDENBMh3XeqaECBloHip1+poPIfLDEWSiFenqJmQPdhLmoBgXYMlwDBhA6qQqYAHraNJJumkItqQyGqRGikkSAAZq8BWksqc5ySCLEBYFMNbFac4gmjv7zSCTIhJqrrAVAkUAivUqEgBeSLRSg6LC55pEGDsnC8cgNkRCBKrTcqgBAsTIMcSwQ5JaL7RDaOtvtuuy2O0EEAAA7);
font-family:'Comic Sans MS';
font-weight:bold;
}
a:link { text-decoration: none; color: #083d8d; }
a:visited { text-decoration: none; color: #083d8d; }
a:active { text-decoration: underline; color: #000000; }
a:hover { text-decoration: underline; color: #000000; }
a:focus { outline: none; }
.math { font-family: "Times New Roman"; font-size: 1.6em; padding-left: 6px; font-weight: normal;}
.mathsymbol { font-family: "Times New Roman"; font-size: 1.2em; font-weight: normal; }
.text { font-family: "Times New Roman", Times, serif; font-size: 1.2em }
.code { font-family: "Courier New"; font-size: 1.0em; padding-left: 6px;}
.codebg { font-family: "Courier New"; font-size: 1.0em; color: #000000; background:#f0f0f0; margin-top: 0px; margin-bottom: 0px; padding: 10px; }
.codebg.p { font-family: "Courier New"; font-size: 1.0em; color: #000000; background:#f0f0f0; margin-top: 0px; margin-bottom: 0px;}
p.code { font-family: "Courier New"; font-size: 1.0em; color: #000000; background:#f0f0f0; margin:0px; padding:5px; border-width:1px; border-color:#ccc; border-style:solid; line-height:20px}
p.wcode { font-family: "Courier New"; font-size: 1.0em; color: #000000}
p.tcode { font-family: "Courier New"; font-size: 1.0em; color: #000000; background:#f0f0f0; margin:0px; padding:5px; border-width:1px; border-color:#ccc; border-style:solid; line-height:20px }
.table1 .hov { border: 2px black solid; padding: 4px; }
.table1 .ho2 { border: 2px #707070 solid; padding: 4px; }
.table1 .td { border: 1px black solid; padding: 5px; }
table.dtable, table.ntable { border: 1px #ccc solid; border-collapse:collapse; padding: 5px;}
table.dtable th, table.dtable td, table.ntable th, table.ntable td { border: 1px #ccc solid; border-collapse:collapse; padding: 5px; font-weight:normal;}
table.dtable th, table.ntable th { text-align:center }
table.ntable td { text-align:right }
table.calc, .calc2 {
border-spacing: 0px;
border-collapse: separate;
background: #e8e8e8;
border:1px #ddd solid;
border-radius:7px;
-moz-border-radius:7px;
-webkit-border-radius:7px;
}
table.calc td, .calc2 td {
padding: 2px;
border-width: 0px;
border-style: none;
background: #e8e8e8;
}
.calc2 select { padding:4px 2px; font-size:1.2em; font-family:Arial, Helvetica, sans-serif }
@media all and (max-width: 576px) {
.calc2 { padding:8px; margin-left:auto; margin-right:auto; }
.calc2 td { float:left; }
.calc2 td:nth-child(2) { clear:left; }
.calc2 tr td:nth-child(3) { padding-top:10px; }
.calc2 input[type=text], .calc2 input[type=number], .calc2 input[type=url] { width:190px; font-size:x-large; padding-left:3px; }
.calc2 tr td:nth-child(3) select { margin-top:-8px; }
}
@media all and (min-width: 577px) {
.calc2 { padding:15px; }
.calc2 tr { line-height:40px; }
.calc2 input[type=text], .calc2 input[type=number], .calc2 input[type=url] { width:220px; font-size:x-large; padding-left:3px; }
}
</style>
<script type='text/javascript'>
//<![CDATA[
function setfocus() {
document.calcform.x.focus();
}
function calc() {
x = document.calcform.x.value;
y = convert(x);
y = roundresult(y);
document.calcform.y.value = y;
}
function calctest() {
x = document.calcform.x.value;
y = convert(x);
//y = roundresult(y);
y = roundresult1(y);
document.calcform.y.value = y;
}
function calc3() {
x1 = document.calcform.x1.value;
x2 = document.calcform.x2.value;
y = convert(x1,x2);
y = roundresult(y);
document.calcform.y.value = y;
}
function calc4() {
x1 = document.calcform.x1.value;
x2 = document.calcform.x2.value;
x3 = document.calcform.x3.value;
y = convert(x1,x2,x3);
y = roundresult(y);
//yy = y.toString();
//if( yy.length>12 ) {
// y = parseFloat(y);
// y = y.toPrecision(10);
//}
document.calcform.y.value = y;
}
function calc5() {
x = document.calcform.x.value;
y = convert1(x);
y = roundresult(y);
document.calcform.y1.value = y;
y = convert2(x);
y = roundresult(y);
document.calcform.y2.value = y;
}
function calcbase(b1,b2) {
x = document.calcform.x.value;
document.calcform.y.value = convertbase(x,b1,b2);
}
function calcbase2() {
x = document.calcform.x.value;
y = convert(x);
document.calcform.y.value = y;
}
function roundresult(x) {
y = parseFloat(x);
y = roundnum(y,10);
return y;
}
function roundnum(x,p) {
var i;
var n=parseFloat(x);
var m=n.toPrecision(p+1);
var y=String(m);
i=y.indexOf('e');
if( i==-1 ) i=y.length;
j=y.indexOf('.');
if( i>j && j!=-1 )
{
while(i>0)
{
if(y.charAt(--i)=='0')
y = removeAt(y,i);
else
break;
}
if(y.charAt(i)=='.')
y = removeAt(y,i);
}
return y;
}
function removeAt(s,i) {
s = s.substring(0,i)+s.substring(i+1,s.length);
return s;
}
function convertbase(x,b1,b2) {
d="0123456789ABCDEFX";
x=x.replace(/ /,"");
x=x.toUpperCase();
y=0;
// return b1+b2;
for(i=x.length, s=1; i>=1; i--,s*=b1) {
c = x.charAt(i-1);
for(j=0; j<b1+1; j++) {
if( j==b1 ) {
y = "bad input number";
return y;
}
if( c == d.charAt(j) )
break;
}
y+=j*s;
}
x=y;
if( x==0 ) return "0";
y="";
for(s=1; s<=x; s*=b2);
if( x!=s ) s/=b2;
for(p=s; p>=1; p/=b2) {
i = Math.floor(x/p);
y+= d.charAt(i);
x-= i*p;
}
return y;
}
function convertbase2(x,b1,b2) {
x = parseInt(x, b1);
y = x.toString(b2);
return y;
}
var gcd = function(a, b) {
if ( ! b) {
return a;
}
return gcd(b, a % b);
};
function digits_after_period(x)
{
f = x.toString();
i = f.indexOf('.');
len = f.length-i-1;
return len;
}
function parseFraction(s)
{
var n1=n2=0;
var sign=n3=1;
i = s.indexOf(' ');
if( i==0 ) s=s.substring(1);
i = s.indexOf('-');
if( i==0 ) {s=s.substring(1); sign=-1;}
i = s.indexOf(' ');
if( i==0 ) s=s.substring(1);
i = s.indexOf(' ');
if( !isNaN(parseInt(s)) && isFinite(s) ) i=s.length;
if( i!=-1 )
{
n1 = parseInt(s.substring(0,i));
s = s.substring(i+1);
}
i = s.indexOf('/');
if( i!=-1 )
{
n2 = parseInt(s.substring(0,i));
s = s.substring(i+1);
n3 = parseInt(s);
}
return [sign,n1,n2,n3];
}
//]]>
</script>
</head>
<body>
<section id="doc">
<!-- #BeginEditable "doctext" -->
<h1>Binary to Decimal converter</h1>
<p>Binary to decimal number conversion calculator and how to convert.</p>
<h2>Binary to decimal converter</h2>
<p>Enter a binary number and press <i>Convert</i> button:</p>
<form name="calcform">
<table class="calc2">
<tbody>
<tr>
<td><label for="x">Enter binary number:</label></td>
<td class="math"><input type="text" id="x" name="x" class="intext" autofocus tabindex="1"></td>
<td class="mathsymbol"><sub>2</sub></td>
</tr>
<tr>
<td> </td>
<td><input onclick="calcbase2()" type="button" value="Convert" class="btn" tabindex="2"> <input type="reset" value="Reset" class="btn" tabindex="3"></td>
<td> </td>
</tr>
<tr>
<td>Decimal result:</td>
<td class="math"><input type="text" name="y" class="outtext" readonly tabindex="4"></td>
<td class="mathsymbol"><sub>10</sub></td>
</tr>
<tr id="pf1">
<td>Calculation:</td>
<td><textarea name="TA" rows="6" class="outtext" readonly style="width:100%; font-size:large"></textarea></td>
<td> </td>
</tr>
</tbody>
</table>
</form>
<h2>How to convert binary to decimal</h2>
<p>The decimal number is equal to the sum of powers of 2 of the binary number's '1' digits place:</p>
<table class="dtable">
<tr>
<th>binary number:</th>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<th>power of 2:</th>
<td>2<sup>5</sup></td>
<td>2<sup>4</sup></td>
<td>2<sup>3</sup></td>
<td>2<sup>2</sup></td>
<td>2<sup>1</sup></td>
<td>2<sup>0</sup></td>
</tr>
</table>
<p class="math">111001<sub>2</sub> = 1·2<sup>5</sup>+1·2<sup>4</sup>+1·2<sup>3</sup>+0·2<sup>2</sup>+0·2<sup>1</sup>+1·2<sup>0</sup> = 57</p>
<h2>Binary to decimal conversion table</h2>
<table class="ntable">
<tr>
<th>Binary<p>base 2</th>
<th>Decimal<p>base 10</th>
</tr>
<tr>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>10</td>
<td>2</td>
</tr>
<tr>
<td>11</td>
<td>3</td>
</tr>
<tr>
<td>100</td>
<td>4</td>
</tr>
<tr>
<td>101</td>
<td>5</td>
</tr>
<tr>
<td>110</td>
<td>6</td>
</tr>
<tr>
<td>111</td>
<td>7</td>
</tr>
<tr>
<td>1000</td>
<td>8</td>
</tr>
<tr>
<td>1001</td>
<td>9</td>
</tr>
<tr>
<td>1010</td>
<td>10</td>
</tr>
<tr>
<td>1011</td>
<td>11</td>
</tr>
<tr>
<td>1100</td>
<td>12</td>
</tr>
<tr>
<td>1101</td>
<td>13</td>
</tr>
<tr>
<td>1110</td>
<td>14</td>
</tr>
<tr>
<td>1111</td>
<td>15</td>
</tr>
<tr>
<td>10000</td>
<td>16</td>
</tr>
<tr>
<td>100000</td>
<td>32</td>
</tr>
<tr>
<td>1000000</td>
<td>64</td>
</tr>
<tr>
<td>10000000</td>
<td>128</td>
</tr>
<tr>
<td>100000000</td>
<td>256</td>
</tr>
</table>
<script type="text/javascript">
<!--
function calcbase2() {
x = document.calcform.x.value;
y = parseInt(x,2);
y2 = y;
if( (y<0x100) && (y&0x80) )
y2 -= 0x100;
else if( (y<0x10000) && (y&0x8000) )
y2 -= 0x10000;
else if( (y<0x100000000) && (y&0x80000000) )
y2 -= 0x100000000;
document.calcform.y.value = y;
var row1 = document.getElementById("pf1");
//var row2 = document.getElementById("pf2");
row1.style.display = '';
//row2.style.display = '';
var txt="Binary = "+x;
x = x.toString();
var len=x.length;
var look=["\u2070","\u00B9","\u00B2","\u00B3","\u2074","\u2075","\u2076","\u2077","\u2078","\u2079"];
if( len>0 )
{
txt+="\nDecimal= "
for(var i=0; i<len; i++)
{
var p = len-1-i;
var d = x.charAt(i);
var n = parseInt(d,2);
if( isNaN(n) ) { alert("Input number is not binary"); return; }
var d2='';
if( p>9 ) d2=look[Math.floor(p/10)];
var d1=look[p%10];
txt+=n+"\u00D72"+d2+d1;
if( i<len-1 ) txt+="+";
}
txt+=" = "+y;
txt+="\nSigned decimal = "+y2;
txt+="\nHex = "+y.toString(16).toUpperCase();
}
document.calcform.TA.value = txt;
}
//-->
</script>
<!-- #EndEditable -->
</section>
</body>
</html>
Related movie you might like to see :

COMMENTS REMOVER CODE

COMMENTS REMOVER

FILE SAVE AS WITH JAVA SCRIPT METHO...

FILE SAVE AS WITH JAVA SCRIPT METH...

HTML CSS JAVA COMPRESSOR CODE

HTML CSS JAVA COMPRESSOR

ONLINE CSS UNMINIFIER CODE

ONLINE CSS UNMINIFIER

CSSO (CSS Optimizer)

SCRIPT TUTORIALS CSSO CSS COMPOSER ...

WHITE SPACE REMOVER CODE

White Space Remover
?
+
X
Recommended for you
Loading..
Related Post for BINARY TO DECIMAL CODE
PRIME FACTORS BRANCH CALCULATOR PRIME FACTORS /* AngularJS v1.2.20 (c) 2010-2014 Google, Inc. http://angularjs.org License: MIT */ (function(S,U,s){'use strict';function v(b){return function(){var …
HOW MANY DIVISORS DOES A NUMBER HAVE? -------------------------------------------------------------------------------------------------------------------------- READ MORE: http://www.javascripter.net/math/calculat…
HOW MANY DIVISORS DOES A NUMBER HAVE? -------------------------------------------------------------------------------------------------------------------------- READ MORE: http://primes.utm.edu/glossary/xpage/tau.…
HCF AND LCM WITH BRACH METHOD CALCULATOR CODE ----------------------------------------------------------------------------------------------------------------- COPY AND PASTE BELOW CODE IN POST HTML SECTION ---------------…
LINEAR EQUATION CALCULATOR CODE ----------------------------------------------------------------------------------------------------------------- COPY AND PASTE BELOW CODE IN POST HTML SECTION ---------------…
PRIME FACTORS BRANCH CALCULATOR CODE ----------------------------------------------------------------------------------------------------------------- COPY AND PASTE BELOW CODE IN POST HTML SECTION ---------------…
GREATEST COMMON FACTOR CALCULATOR CODE -------------------------------------------------------------------------------------------------------------------------- READ MORE: http://maths.wordpandit.com/h-c-f-by-…
HCF AND LCM WITH BRACH METHOD CALCULATOR HIGHEST COMMON FACTOR AND LOWEST COMMON MULTIPLE /* AngularJS v1.2.20 (c) 2010-2014 Google, Inc. http://angularjs.org License: MIT */ (function(S,U,s){'use strict';fu…
LINEAR EQUATION CALCULATOR #parse_btn { background-color:Blue; color:#FFFFFF; font-size:30px; width:200px; height:50px; } x=3;y=7 Calculate it! Solve Graph Lesson Sh…
Labels:
TEXT TOOLS
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.