真的猜对了
一个ASCII字符一般是一byte是占用8个bit (二进制)
agent大侠的算法应该是用位实现的(我今天没时间down下来研究)

这里有关于perl位运算的文档

http://perldoc.perl.org/perlop.html#Bitwise-And

2009/9/23 Beckheng Lam <[email protected]>

> 0b是二进制数值 就好像0x是十六进制 0... 会表示为八进制一样。
>
> 以上纯属猜测,如有雷同,实属撞。。。
>
> 空格 wrote:
> > 这个似乎是目前最节省内存的方法,不过我还是不太明白。
> > 在perl里如何实现你说的这个二进制的bit运算?抱歉我不知道用什么语句能实现这个“2位表示一个字符”。
> > 另外这个:
> > $char = $key & 0b000011;
> > 我也不太明白, & 后面的这个0b000011如果就是转换了的bit运算结果,那么0b对应什么意思?
> >
> >
> > On 9月23日, 下午5时49分, truncatei <[email protected]> wrote:
> >
> >> bit运算应该是这样:
> >> 2位表示一个字符
> >> 00 A
> >> 01 G
> >> 10 T
> >> 11 C
> >>
> >> 这样下来一个15个字符的序列一共30位,一个int足矣,必用字符串省很多内存
> >>
> >> 取各个位
> >> 如:
> >> $char = $key & 0b000011;
> >> $char = $key & 0b001100;
> >> $char = $key & 0b110000
> >> ...
> >> 取出每个位以后再做判断
> >> $char == 0;
> >> $char == 1;
> >> $char == 2;
> >> $char == 4;
> >>
> >> 2009/9/23 空格 <[email protected]>
> >>
> >>
> >>> 我昏了,之前我把00,01,10,11理解成十进制的数字了。
> >>> 就是说,
> >>> 当取到一个字串赋给$key之后,
> >>> $key=~s{A}{0}g;
> >>> $key=~s{G}{1}g;
> >>> $key=~s{T}{2}g;
> >>> $key=~s{C}{3}g;
> >>> 再用 exists(%hash{$key}); 检查是否有特定键值。是这样的吧?
> >>>
> >>> On 9月23日, 上午11时17分, msmouse <[email protected]> wrote:
> >>>
> >>>> 就是这个意思。前面agentzh说:
> >>>> ”事先约定 A,T,G,C 分别对应 00, 01, 10, 11,即 2 个比特的数值。“
> >>>> 即用两个位表示一个字符,15个字符即是30位。30个二进制位即是15个4进制位
> >>>> ----------------------------------
> >>>> [email protected]
> >>>> [email protected]
> >>>>
>
> --
> Perl乐事 -- http://www.perlersh.org
> 我的博客 -- http://www.perlersh.org/blog.html
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“PerlChina Mongers 讨论组”论坛。
 要在此论坛发帖,请发电子邮件到 [email protected]
 要退订此论坛,请发邮件至 [email protected]
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---

回复