home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2000 April
/
VPR0004B.BIN
/
DRIVER
/
COMPAQ
/
SP12255
/
sp12255.exe
/
DMWEBC1.CAB
/
NUMCNVRT.JS
< prev
next >
Wrap
Text File
|
1999-01-18
|
2KB
|
71 lines
// $Id: NUMCNVRT.JS 1.1 1998/01/22 20:13:28 cboeker Q/A $
// Copyright (C) 1998 Compaq Computer Corporation
// Need to make this go higher
function hexfromdec(num) {
if (num > 65535) { return ("Max is 65535") }
first = Math.round(num/4096 - .5);
temp1 = num - first * 4096;
second = Math.round(temp1/256 -.5);
temp2 = temp1 - second * 256;
third = Math.round(temp2/16 - .5);
fourth = temp2 - third * 16;
return (""+getletter(first)+getletter(second)+getletter(third)+getletter(fourth));
}
function getletter(num) {
if (num < 10) {
return num;
}
else {
if (num == 10) { return "A" }
if (num == 11) { return "B" }
if (num == 12) { return "C" }
if (num == 13) { return "D" }
if (num == 14) { return "E" }
if (num == 15) { return "F" }
}
}
function decfromhex(num) {
while (num.length < 4) {
num = "0" + num;
}
return (eval(getnum(num.substring(3,4))) + eval(getnum(num.substring(2,3))) * 16 +
eval(getnum(num.substring(1,2))) * 256 + eval(getnum(num.substring(0,1))) * 4096);
}
function getnum(letter) {
if (letter <= "9") {
return letter;
}
else {
if ((letter == "a") || (letter == "A")) { return 10 }
if ((letter == "b") || (letter == "B")) { return 11 }
if ((letter == "c") || (letter == "C")) { return 12 }
if ((letter == "d") || (letter == "D")) { return 13 }
if ((letter == "e") || (letter == "E")) { return 14 }
if ((letter == "f") || (letter == "F")) { return 15 }
return 0;
}
}
function rawToHex( rawIn, spacer )
{
var i;
var rc = "";
if( null == spacer )
{
spacer = "";
}
for(i=0; i<rawIn.length; i++)
{
rc += hexfromdec( rawIn[i] ).substring(2,4) + spacer;
}
return rc;
}