VBS and JS combined to make up for the shortage of ASP bit operation

Source: Internet
Author: User
Tags bitwise
The js| operator uses a VBS in the majority of ASP users, because it is simple, but also because the simple VBS has its drawbacks, such as the VBS does not support bit operations, in this respect JavaScript is very good, the following JavaScript in the bit operation through the function of encapsulation to use in the VBS

The following files can be used to perform bitwise operations directly using the functions defined therein
<script language=javascript runat= "Server" >
function Bitand (VAL1,VAL2)
{
Return val1&val2; Bitwise AND
}
function Bitor (VAL1,VAL2)
{
return val1|val2; by bit or
}
Function Bitnot (val)
{
return ~val; Reverse by position
}
function Bitxor (VAL1,VAL2)
{
return val1^val2; Per-bitwise XOR OR
}
function Ubitright (val,n)
{
Return val>>>n; No sign Right move
}
function Bitleft (val,n)
{
Return val<<n; Move left
}
function Bitright (val,n)
{
Return val>>n; Move right
}
</script>

Related Article

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.