|
s11ss
银牌会员
积分 2098
发帖 566
注册 2007-9-11
状态 离线
|
『楼 主』:
[原创]*********十进制转其它进制**********
@echo off
setlocal enabledelayedexpansion
::::::::::::::::::::::::::10 to 2,8,16 {s11ss 2007-9-18}::::::::::::::::::::::::::
echo Please input a number expressed in decimalism :(Assuming that it possesses 2 bytes.)
:Rec
set /p num=
if !num! gtr 32767 (call :w)
if !num! lss -32767 (call :w)
if !num! equ 0 (echo. & echo No matter what system it is expressed in,it's always 0. & goto :eof)
set /a flag=1
if !num! lss 0 (set /a num=65536+!num! & set /a flag=-1)
echo.
echo Calculating...
if !num! gtr 0 (
for %%a in (2,8,16) do (
set /a counter=0
set /a quotient=!num!
set result=
call :n %%a
call :c %%a
call :p %%a
)
goto :eof
)
:w
echo.
echo Error.The number's value is allowed in [-32767,32767] only.Please try again.
goto :Rec
:n
set /a remainder=!quotient!%%%1
set /a quotient=!quotient!/%1
if %1 equ 16 (
call :16 10 A
call :16 11 B
call :16 12 C
call :16 13 D
call :16 14 E
call :16 15 F
)
set result=!remainder!!result!
set /a counter+=1
if !quotient! equ 0 (goto :eof) else (goto :n)
:16
if !remainder! equ %1 set remainder=%2
goto :eof
:p
if %1 equ 2 (
set newrslt=!result:~0,4!
for /l %%a in (4,4,16) do (
set newrslt=!newrslt! !result:~%%a,4!
)
set t=1.Binary:
set result=!newrslt!
echo.
echo The result is :
)
if %1 equ 8 (set t=2.Octal:)
if %1 equ 16 (set t=3.Hex:)
echo.
echo !t!
echo !result!
goto :eof
:c
if %1 equ 2 (set a=16& set b=0& set c=1)
if %1 equ 8 (set a=6& set b=0& set c=1)
if %1 equ 16 (set a=4& set b=0& set c=F)
if not !counter! equ !a! (
set /a cnum=!a!-!counter!
if !flag! equ 1 (set cch=!b!) else (set cch=!c!)
for /l %%a in (1,1,!cnum!) do (set result=!cch!!result!)
)
goto :eof
|
|
2007-9-18 17:18 |
|
|
wudixin96
银牌会员
积分 1928
发帖 931
注册 2007-1-6
状态 离线
|
『第
2 楼』:
呵呵,楼主真有意思,每天一原创。
加分加分
|
|
2007-9-18 17:52 |
|
|
vkill
金牌会员
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第
3 楼』:
10 to 16 可以试试 ping
|
|
2007-9-18 20:15 |
|
|
s11ss
银牌会员
积分 2098
发帖 566
注册 2007-9-11
状态 离线
|
『第
4 楼』:
Quote: | Originally posted by vkill at 2007-9-18 08:15 PM:
10 to 16 可以试试 ping |
|
ping ?延时?
|
|
2007-9-18 23:24 |
|
|
scriptor
银牌会员
积分 1187
发帖 555
注册 2006-12-21
状态 离线
|
『第
5 楼』:
这个好似我以前写过一个任意进制的
呵呵...
鼓励原创.......加油啊!!
|
|
2007-9-19 00:15 |
|
|
vkill
金牌会员
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第
6 楼』:
Quote: | Originally posted by s11ss at 2007-9-18 23:24:
ping ?延时? |
|
for 来处理ping的回显
|
|
2007-9-19 21:02 |
|
|
s11ss
银牌会员
积分 2098
发帖 566
注册 2007-9-11
状态 离线
|
『第
7 楼』:
Quote: | Originally posted by vkill at 2007-9-19 09:02 PM:
for 来处理ping的回显 |
|
请问与进制转换有关系么?
|
|
2007-9-19 23:11 |
|
|
lxmxn
版主
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第
8 楼』:
Quote: | Originally posted by s11ss at 2007-9-19 23:11:
请问与进制转换有关系么? |
|
可以用ping命令简单实现10到16进制的转换,论坛以前有过讨论,搜索一下先?
|
|
2007-9-19 23:59 |
|
|
zh159
金牌会员
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第
9 楼』:
这是收藏的一段进制转换器,原来是html的,我把它改为HTA了
<HTML>
<HEAD>
<TITLE>进制转换器 v1.0</TITLE>
<HTA:APPLICATION
ID="MyhyliApp"
APPLICATIONNAME="进制转换器 v1.0"
VERSION="1.0"
SCROLL="no"
INNERBORDER="no"
CONTEXTMENU="no"
CAPTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
NAVIGABLE="yes"
/>
<SCRIPT language="JavaScript">
window.resizeTo(350, 270);
ileft=(window.screen.width-350)/2;
itop=(window.screen.height-270)/2;
window.moveTo(ileft,itop);
function convert()
{
var num;
var idx = option1.selectedIndex;
if (idx == 0)
num = parseInt(input1.value, 10);
if (idx == 1)
num = parseInt(input1.value, 2);
if (idx == 2)
num = parseInt(input1.value, 8);
if (idx == 3)
num = parseInt(input1.value, 16);
var dec = " 十进制:" + num.toString(10);
var bin = " 二进制:" + num.toString(2);
var oct = " 八进制:" + num.toString(8);
var hex = "十六进制:" + num.toString(16).toUpperCase();
edit1.innerText = dec + "\n" + bin + "\n" + oct + "\n" + hex;
input1.select();
}
</SCRIPT>
</HEAD>
<BODY scroll="no" style="border: 1 solid #9ab8f6;FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#10bfff,endColorStr=#007db2);cursor:hand;color:#ffffff;">
<SELECT NAME="option1" SIZE="1">
<OPTION>十进制<OPTION>二进制<OPTION>八进制<OPTION>十六进制
</SELECT>
<INPUT name="input1">
<BUTTON onclick="convert()" type="submit" style="border: 1 solid #9ab8f6;FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#10bfff,endColorStr=#007db2);cursor:hand;color:#ffffff;">转换</BUTTON><BR><BR>
转换结果:<BR>
<span id="edit1" style="width:300; height:100"> 十进制:<BR>
二进制:<BR>
八进制:<BR>
十六进制:
</span>
</BODY>
</HTML>
|
|
|
2007-9-20 00:38 |
|
|
s11ss
银牌会员
积分 2098
发帖 566
注册 2007-9-11
状态 离线
|
『第
10 楼』:
Quote: | Originally posted by lxmxn at 2007-9-19 11:59 PM:
可以用ping命令简单实现10到16进制的转换,论坛以前有过讨论,搜索一下先? |
|
又长见识了,呵呵~~
|
|
2007-9-20 15:26 |
|