Super (Infinity) Large---integer 10 binary data and 16-binary data conversion

Source: Internet
Author: User

<title> Super (Infinity) Large---integer 10 binary data with 16 binary data conversion </title>
<meta charset= "Utf-8"/>
<meta name= "keywords" content= "data compression algorithm, large data arithmetic operations over integer representation range, large binary data conversion"/>
<meta name= "keywords" content= "efficient multiplication method of vertical calculation model, multiplication into addition operation, division into subtraction operation"/>
<meta name= "keywords" content= "original author: [email protected]"/>
<script type= "Text/javascript" >


function Test16to10 () {
var arr= document.getelementsbytagname ("input");
for (Var i=0;i<arr.length;i++) {
if ((Arr[i].type = = "text") && (Arr[i].name = = "A0116")) {
Document.getelementsbyname ("A0110") [0].value = Convertbig16toint (Arr[i].value);
parseint (arr[i].value,16). toString (10);
}
}
}


function Test10to16 () {
var arr= document.getelementsbytagname ("input");
for (Var i=0;i<arr.length;i++) {
if ((Arr[i].type = = "text") && (Arr[i].name = = "B0110")) {
Document.getelementsbyname ("B0116") [0].value = ConvertBigIntTo16 (Arr[i].value);
parseint (arr[i].value,10). toString (16);
}
}
}


function convertBigIntTo16 (data) {
data = Data.replace (/^ (\s|\xa0) +| ( \S|\XA0) +$/g, ");
var datalength = data.length;
if (IsNaN (data) | | datalength = = 0) return ';
var Yushu = 0;
var shang = 0;
var x = 0;
var index = 0;
var Yushuarr = new Array ();
var Shangarr = new Array ();
while (Datalength > 1) {
Yushu = 0;
Shang = 0;
x = 0;
index = 0;
Shangarr = [];
while (Index < datalength) {
while (Index < datalength) {
x = Yushu * + parseint (DATA.SUBSTR (index,1));
Yushu = x;
if (x > 15) {
index = index + 1;
Break
}else if (Index > 1) && (index + 1! = datalength)) {
Shangarr.push (' 0 ');
}
index = index + 1;
}
Shang = parseint (X/16);
Yushu = x 16;
Shangarr.push (Shang.tostring ());
}
Yushuarr.push (Yushu.tostring ());
data = Shangarr.join (");
Datalength = Data.length;
}

if (datalength = = 1) yushuarr.push (data);
for (var i = 0; i < yushuarr.length; i++) {
if (yushuarr[i] = = 10)
Yushuarr[i] = "a";
else if (yushuarr[i] = = 11)
Yushuarr[i] = "B";
else if (yushuarr[i] = = 12)
Yushuarr[i] = "C";
else if (yushuarr[i] = = 13)
Yushuarr[i] = "D";
else if (yushuarr[i] = = 14)
Yushuarr[i] = "E";
else if (yushuarr[i] = = 15)
Yushuarr[i] = "F";
}
if (yushuarr[yushuarr.length-1] = = ' 0 ')
Yushuarr.pop ();
var result = Yushuarr.reverse (). Join (');
return result;
}


function Convertbig16toint (data) {
data = Data.replace (/^ (\s|\xa0) +| ( \S|\XA0) +$/g, ");
var datalength = data.length;
if (datalength = = 0) return ';
var index = 0;
var x = 0;
var Gearr = new Array ();
var Getohigharr = new Array ();
var Shitohigharr = new Array ();
var Yushuarr = new Array ();
var Resultarr = new Array ();
Resultarr[0] = ' 0 ';
var arr16 = new Array ();
arr16[' 0 '] = ' 0 ';
arr16[' 1 '] = ' 1 ';
arr16[' 2 '] = ' 2 ';
arr16[' 3 '] = ' 3 ';
arr16[' 4 '] = ' 4 ';
arr16[' 5 '] = ' 5 ';
arr16[' 6 '] = ' 6 ';
arr16[' 7 '] = ' 7 ';
arr16[' 8 '] = ' 8 ';
arr16[' 9 '] = ' 9 ';
Arr16[' a '] = ' 10 ';
Arr16[' b '] = ' 11 ';
Arr16[' c '] = ' 12 ';
arr16[' d '] = ' 13 ';
Arr16[' e '] = ' 14 ';
arr16[' f '] = ' 15 ';
while (Index < datalength) {
Gearr = Resultarr;
Resultarr = [];
Getohigharr = [];
for (Var i=0;i<gearr.length;i++) {
x = 0;
x = parseint (i < gearr.length? Gearr[i]: ' 0 ') * 6;
x = x + parseint (i < getohigharr.length getohigharr[i]: ' 0 ');
Getohigharr[i] = x% 10;
if (x > 0)
Getohigharr[i+1] = parseint (X/10);
}
Shitohigharr = [];
Gearr.unshift (0);
for (Var i=0;i<gearr.length;i++) {
x = 0;
x = parseint (i < gearr.length gearr[i]: ' 0 ');
x = x + parseint (i < getohigharr.length getohigharr[i]: ' 0 ');
x = x + parseint (i < shitohigharr.length shitohigharr[i]: ' 0 ');
Shitohigharr[i] = x% 10;
if (x > 0)
Shitohigharr[i+1] = parseint (X/10);
}
Gearr = [];
Yushuarr = [];
Yushuarr = Arr16[data.substr (index,1)].split ("). reverse ();
for (Var i=0;i<shitohigharr.length;i++) {
x = 0;
x = x + parseint (i < shitohigharr.length shitohigharr[i]: ' 0 ');
x = x + parseint (i < yushuarr.length yushuarr[i]: ' 0 ');
x = x + parseint (i < resultarr.length resultarr[i]: ' 0 ');
Resultarr[i] = x% 10;
if (x > 9)
Resultarr[i+1] = parseint (X/10);
}
index = index + 1;
}
if (resultarr[resultarr.length-1] = = 0)
Resultarr.pop ();
var result = Resultarr.reverse (). Join (');
return result;
}


</script>
<body>
<div><b> decimal Number: 160,016,000,166 binary number: 3b9c50a10 </b></div><br>
<div><b> decimal Number: 16,001,600,006 binary number: 5f608100 </b></div><br& Gt
<div><b> decimal Number: 1.,234,567,890,123,46e,+20 binary number: Ab54a98ceb1f0ad2 </b></div><br>
<div><b> decimal Number: 1.,266,200,110,727,09e,+20 binary number: afb876ebc07c44b3 </b></div><br>
<div><b> decimal Number: 4.,721,702,174,050,93e,+19 binary number: 4186db1c537ecaa8 </b></div><br>
<div><b> decimal Number: 1.,627,933,471,035,88e,+20 binary number: e1ebd0aadea0385d </b></div><br>
<div><b> decimal Number: 1.,449,931,142,501,45e,+20 binary number: c937e6eb9fc06e9a </b></div><br>
<div><b> decimal Number: 1.,837,919,108,197,74e,+20 binary number: ff1000e97449df81 </b></div><br>
<div><b> decimal Number: 3.,228,213,681,276,04e,+19 binary number: 2ccceb3d4383b157 </b></div><br>
<div id= "XY" >
<div><b> hexadecimal number converted to decimal number </b></div><br>
Hex: <input type= "text" name= "A0116"/> Decimal number: <input type= "text" name= "A0110" readonly= "readonly"/><br >
<input type= "button" value= "Start Conversion" onclick= "Test16to10 ()"/><br><br>
</div>
<div id= "xyz" >
<div><b> decimal number converted to hexadecimal number </b></div><br>
Decimal number: <input type= "text" name= "B0110"/> 16 binary: <input type= "text" name= "B0116" readonly= "readonly"/><br >
<input type= "button" value= "Start Conversion" onclick= "test10to16 ()"/>
</div>
</body>

Super (Infinity) Large---integer 10 binary data and 16-binary data conversion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.