最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

bitflags - How to calculate Bit Flag in javascript? - Stack Overflow

programmeradmin8浏览0评论

im writing a free tool for SEO... implementing an api from seomoz and the flags look like this

URL Metric,Bit Flag
Title,1
URL,4
Subdomain,8
Root Domain,16
External Links,32
Links,2048
mozRank,16384
mozTrust,131072

these are just a few but i dont know how to calculate the proper bit flag in javascript... is it just an OR of all the integers of the flags i want to use? a small snippet to show me how to make a var that holds some of these flags would be awesome...

thanks for your help!

im writing a free tool for SEO... implementing an api from seomoz and the flags look like this

URL Metric,Bit Flag
Title,1
URL,4
Subdomain,8
Root Domain,16
External Links,32
Links,2048
mozRank,16384
mozTrust,131072

these are just a few but i dont know how to calculate the proper bit flag in javascript... is it just an OR of all the integers of the flags i want to use? a small snippet to show me how to make a var that holds some of these flags would be awesome...

thanks for your help!

Share Improve this question asked Jan 31, 2010 at 16:49 Carter ColeCarter Cole 9249 silver badges16 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Just like in C:

var flags = 0;
// *snip*
flags |= MyFlag;
flags |= MyOtherFlag;
// *snip*
if ((flags & MyFlag) == MyFlag)
{
    // do stuff
}

is it just an OR of all the integers of the flags i want to use?

Yes. Title|URL|Links (etc.) would be 1|4|2048

发布评论

评论列表(0)

  1. 暂无评论