📄 airconditioner.txt
字号:
function RemoveBlanks(input)
{
output = new String()
var start, stop
start = 0
while ((input.charAt(start) == " ") && (start < input.length))
start++
stop = input.length - 1
while ((input.charAt(stop) == " ") && (stop >= 0))
stop--
output = input.substring(start, stop + 1)
return output
}
function Convert2Hex()
{
output = new String()
numerals = new String()
var temp, index, i
numerals = "0123456789ABCDEF"
with (Math)
{
//convert binary result to hex and output
for (index = 0; index < this.Size; index +=4)
{
temp = 0
for (i = 0; i < 4; i++)
temp += pow(2, 3 - i)*this.Result[index + i]
output = output + numerals.charAt(temp)
}
}
return output
}
function numStrClipOff(input, precision)
{
result = new String()
numerals = new String()
tempstr = new String()
expstr = new String()
signstr = new String()
var locE, stop, expnum, locDP, start, MSD, MSDfound, index, expdelta, digits
var number
numerals = "0123456789";
tempstr = input.toUpperCase()
locE = tempstr.indexOf("E");
if (locE != -1)
{
stop = locE
expstr = input.substring(locE + 1, input.length)
expnum = expstr * 1
}
else
{
stop = input.length
expnum = 0
}
if (input.indexOf(".") == -1)
{
tempstr = input.substring(0, stop)
tempstr += "."
if (input.length != stop)
tempstr += input.substring(locE, input.length)
input = tempstr
locE = locE + 1
stop = stop + 1
}
locDP = input.indexOf(".");
start = 0
if (input.charAt(start) == "-")
{
start++
signstr = "-"
}
else
signstr = ""
MSD = start
MSDfound = false
while ((MSD < stop) && !MSDfound)
{
index = 1
while (index < numerals.length)
{
if (input.charAt(MSD) == numerals.charAt(index))
{
MSDfound = true
break
}
index++
}
MSD++
}
MSD--
if (MSDfound)
{
expdelta = locDP - MSD
if (expdelta > 0)
expdelta = expdelta - 1
expnum = expnum + expdelta
expstr = "e" + expnum
}
else //No significant digits found, value is zero
MSD = start
digits = stop - MSD
tempstr = input.substring(MSD, stop)
if (tempstr.indexOf(".") != -1)
digits = digits - 1
number = digits
if (precision < digits)
number = precision
tempstr = input.substring(MSD, MSD + number + 1)
if ( (MSD != start) || (tempstr.indexOf(".") == -1) )
{
result = signstr
result += input.substring(MSD, MSD + 1)
result += "."
result += input.substring(MSD + 1, MSD + number)
while (digits < precision)
{
result += "0"
digits += 1
}
result += expstr
}
else
{
result = input.substring(0, start + number + 1)
while (digits < precision)
{
result += "0"
digits += 1
}
if (input.length != stop)
result += input.substring(locE, input.length)
}
return result;
}
function numCutOff(input, precision)
{
result = new String()
tempstr = new String()
var temp = input;
if(temp < 1)
temp += 1;
tempstr = "" + temp;
tempstr = numStrClipOff(tempstr, precision);
if(temp == input)
result = tempstr.substring(0, 1);
else
result = "0";
result += tempstr.substring(1, tempstr.length);
return result;
}
function Convert2Dec()
{
output = new String()
var s, i, dp, val, hid, temp, decValue, power
with (Math)
{
if (this.Size == 32) s = 9
else s = 12
if ((this.BinaryPower < this.MinExp) || (this.BinaryPower > this.MaxExp))
{
dp = 0
val = 0
}
else
{
dp = - 1
val = 1
}
for (i = s; i < this.Size; i++)
val += parseInt(this.Result[i])*pow(2, dp + s - i)
decValue = val * pow(2, this.BinaryPower)
this.FullDecValue = decValue
if (this.Size == 32)
{
s = 8
if (val > 0)
{
power = floor( log(decValue) / LN10 )
decValue += 0.5 * pow(10, power - s + 1)
val += 5E-8
}
}
else s = 17
if (this.Result[0] == 1)
{
decValue = - decValue
this.FullDecValue = - this.FullDecValue
}
//the system refuses to display negative "0"s with a minus sign
this.DecValue = "" + decValue
if ((this.DecValue == "0") && (this.Result[0] == 1))
this.DecValue = "-" + this.DecValue
this.DecValue = numStrClipOff(this.DecValue, s)
output = numCutOff(val, s)
}
return output
}
//object construction function
function ieee (Size){
this.Size = Size
this.BinaryPower = 0
this.DecValue = ""
this.FullDecValue = 0
this.DispStr = ""
this.Convert2Bin = Convert2Bin //convert input to bin.
this.Convert2Hex = Convert2Hex //convert bin. to hex.
this.Convert2Dec = Convert2Dec //convert bin. significand to dec.
this.Hex2Bin = Hex2Bin //convert hex. to bin.
this.StatCond = "normal"
this.BinString = ""
// 1 (carry bit) + 1023 + 1 + 1022 + 53 + 2 (round bits)
this.BinVal = new Array(2102) //Binary Representation
if (Size == 32){
this.ExpBias = 127
this.MaxExp = 127
this.MinExp = -126
this.MinUnnormExp = -149
this.Result = new Array(32)
}
else if (Size == 64){
this.ExpBias = 1023
this.MaxExp = 1023
this.MinExp = -1022
this.MinUnnormExp = -1074
this.Result = new Array(64)
}
}
function compute(obj, rounding){
/*
in this javascript program, bit positions are numbered
0 ~ 32/64 from left to right instead of right to left, the
way the output is presented
*/
var index1, cnst
ieee32 = new ieee(32)
ieee64 = new ieee(64)
ieee32.BinString = ieee32.Hex2Bin(obj.hex32b.value)
if (ieee32.BinString != "exit")
{
obj.bin32_0.value = ieee32.BinString.substring(0, 1)
obj.bin32_1.value = ieee32.BinString.substring(1, 9)
if ((ieee32.BinaryPower < ieee32.MinExp) ||
(ieee32.BinaryPower > ieee32.MaxExp))
{
obj.bin32_9.value = " "
obj.bin32_9.value += ieee32.BinString.substring(9, 10)
obj.bin32_9.value += "."
obj.bin32_9.value += ieee32.BinString.substring(10, 32)
}
else
{
obj.bin32_9.value = "1 ."
obj.bin32_9.value += ieee32.BinString.substring(9, 32)
}
obj.stat32.value = ieee32.StatCond
obj.binpwr32.value = ieee32.BinaryPower
obj.binpwr32f.value = ieee32.BinaryPower + ieee32.ExpBias
obj.dec32sig.value = ieee32.Convert2Dec()
if (ieee32.DispStr != "")
{
obj.entered.value = ieee32.DispStr
obj.dec32.value = ieee32.DispStr
obj.dec32sig.value = ""
}
else
{
obj.entered.value = ieee32.FullDecValue
obj.dec32.value = ieee32.DecValue
}
obj.hex32.value = ieee32.Convert2Hex()
cnst = 2102 // 1 (carry bit) + 1023 + 1 + 1022 + 53 + 2 (round bits)
for (index1 = 0; index1 < cnst; index1++)
ieee64.BinVal[index1] = ieee32.BinVal[index1]
ieee64.BinString =
ieee64.Convert2Bin(ieee32.DispStr, ieee32.StatCond, ieee32.Result[0],
ieee32.BinaryPower, false)
obj.bin64_0.value = ieee64.BinString.substring(0, 1)
obj.bin64_1.value = ieee64.BinString.substring(1, 12)
if ((ieee64.BinaryPower < ieee64.MinExp) ||
(ieee64.BinaryPower > ieee64.MaxExp))
{
obj.bin64_12.value = " "
obj.bin64_12.value += ieee64.BinString.substring(12, 13)
obj.bin64_12.value += "."
obj.bin64_12.value += ieee64.BinString.substring(13, 64)
}
else
{
obj.bin64_12.value = "1 ."
obj.bin64_12.value += ieee64.BinString.substring(12, 64)
}
obj.stat64.value = ieee64.StatCond
obj.binpwr64.value = ieee64.BinaryPower
obj.binpwr64f.value = ieee64.BinaryPower + ieee64.ExpBias
obj.dec64sig.value = ieee64.Convert2Dec()
if (ieee64.DispStr != "")
{
obj.dec64.value = ieee64.DispStr
obj.dec64sig.value = ""
}
else
obj.dec64.value = ieee64.DecValue
obj.hex64.value = ieee64.Convert2Hex()
}
}
</SCRIPT>
</HEAD>
<BODY bgcolor= lightblue text=navy>
<basefont size = 4>
<center><font size="+2">IEEE-754 Floating-Point Conversion</font><br>
<font size="+1">
From 32-bit Hexadecimal Representation<br>
To Decimal Floating-Point<br>
Along with the Equivalent 64-bit Hexadecimal and Binary Patterns
</font></center></p>
<form>
Enter the 32-bit hexadecimal representation of a floating-point number here,<br>
then click the <b>Compute</b> button.<br>
<br>
<font size="-1">
Hexadecimal Representation: <input type="text" name="hex32b" size=8>
<input type=reset value="Clear"><br>
<hr width=30%>
<center>
<input type="button" value="Compute" onClick="compute(this.form, false)">
<br>
</center>
<hr width=30%>
<br>
<hr>
<br>
<font size=4>Results:<br><br>
Decimal Value Entered:
<font size="-1"><input type="text" name="entered" size=24></font><br><br><br>
<u>Single precision (32 bits)</u>:</p>
<i>Binary: Status:</i></font>
<font size="-1"><input type="text" name="stat32" size=12></font><br>
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=5><tr align = center><TD>
<pre>Bit 31
Sign Bit
<input type="text" name="bin32_0" size=1>
0: +
1: -
</pre>
</td>
<td>
<pre>
Bits 30 - 23
Exponent Field
<input type="text" name="bin32_1" size=8>
Decimal value of exponent field and exponent
<input type="text" name="binpwr32f" size=3> - 127 = <input type="text" name="binpwr32" size=4>
</pre>
</td>
<td>
<pre>
Bits 22 - 0
Significand
<input type="text" name="bin32_9" size=26>
Decimal value of the significand
<input type="text" name="dec32sig" size=9>
</pre>
</td></tr></table></p>
<font size=4><i>Hexadecimal:</i></font>
<font size="-1"><input type="text" name="hex32" size=8></font>
<font size=4> <i>Decimal:</i></font>
<font size="-1"><input type="text" name="dec32" size=14></font>
</p>
<br><br>
<font size=4>
<u>Double precision (64 bits)</u>:</p>
<i>Binary: Status:</i></font>
<font size="-1"><input type="text" name="stat64" size=12></font><br>
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=5 ><tr align =
center><TD>
<pre>Bit 63
Sign Bit
<input type="text" name="bin64_0" size=1>
0: +
1: -
</pre>
</td>
<td>
<pre>
Bits 62 - 52
Exponent Field
<input type="text" name="bin64_1" size=11>
Decimal value of exponent field and exponent
<input type="text" name="binpwr64f" size=4> - 1023 = <input type="text" name="binpwr64" size=5></pre>
</td>
<td>
<pre>
Bits 51 - 0
Significand
<input type="text" name="bin64_12" size=55>
Decimal value of the significand
<input type="text" name="dec64sig" size=18>
</pre>
</td></tr></table></p>
<font size=4><i>Hexadecimal:</i></font>
<font size="-1"><input type="text" name="hex64" size=16></font>
<font size=4> <i>Decimal:</i></font>
<font size="-1"><input type="text" name="dec64" size=24></font>
</font>
</form>
<br>
<hr>
<br>
<font size="-1">
<center>
[ <a href=
"IEEE-754hex64.html">Convert IEEE-754
64-bit Hexadecimal Representations to Decimal Floating-Point Numbers.</a> ]<br>
[ <a href=
"IEEE-754.html">Convert Decimal
Floating-Point Numbers to IEEE-754 Hexadecimal Representations.</a> ]<br>
[ <a href=
"IEEE-754references.html">Reference
Material on the IEEE-754 Standard.</a> ]<br>
[ <a href= "http://babbage.cs.qc.edu/courses/cs341/index.html">CS-341
Home Page.</a> ]<br>
[ <a href= "http://babbage.cs.qc.edu/index.php">Dr. Vickery's Home
Page.</a> ]<br>
<br>
</center>
</font>
<HR>
<font size="-2">
<i>September 1998</i><br>
This page was created by <a
href="mailto:c2xkjb@eng.delcoelect.com">Kevin J. Brewer</a> of <a
href="http://www.delphiauto.com/index.cfm?location=312">Delco
Electronics</a>. It was inspired by the <a href="IEEE-754.html">floating-point
to hexadecimal conversion page</a>
created by a Queens College undergraduate, <a href =
"mailto:Quanfei.Wen@ca.com">Quanfei Wen</a>, a member of <a
href="http://www.pbk.org">PBK</a> and <a href =
"http://www.qc.edu/~upeqc">UPE</a>.
<br>
</font>
<HR>
</basefont>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -