asp有二进制运算的方式么

独醒子 2009-06-30 04:13:12
字符串
a="001001"
b="111000"

我要得到 a & b = "001000"
以及 a | b = "111001"

的结果,

能告诉我方法么? 谢谢
...全文
53 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
独醒子 2009-06-30
  • 打赏
  • 举报
回复
有碰到一高手 呵呵 开心
谢谢了
hookee 2009-06-30
  • 打赏
  • 举报
回复

a= BinToDec("001001")
b= BinToDec("111000")

c = a And b
d = a Or b

Response.Write DecToBin(c)
Response.Write DecToBin(d)


Function DecToBin(intDec)
dim strResult
dim intValue
dim intExp

strResult = ""

intValue = intDEC
intExp = 65536
while intExp >= 1
if intValue >= intExp then
intValue = intValue - intExp
strResult = strResult & "1"
else
strResult = strResult & "0"
end if
intExp = intExp / 2
wend

DecToBin = strResult
End Function



Function BinToDec(strBin)
dim lngResult
dim intIndex

lngResult = 0
for intIndex = len(strBin) to 1 step -1
strDigit = mid(strBin, intIndex, 1)
select case strDigit
case "0"
' do nothing
case "1"
lngResult = lngResult + (2 ^ (len(strBin)-intIndex))
case else
' invalid binary digit, so the whole thing is invalid
lngResult = 0
intIndex = 0 ' stop the loop
end select
next

BinToDec = lngResult
End Function

独醒子 2009-06-30
  • 打赏
  • 举报
回复
不用javascript呢

<%
vbscript
%>
岑子哥 2009-06-30
  • 打赏
  • 举报
回复
javascript(asp)
为运算符:
<< 左移
>> 右移
~ 非
& 与
| 或
^ 异或

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧