[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78451] [Ruby trunk Feature#12753] Useful operator to check bit-flag is true or false
From:
shugo@...
Date:
2016-12-01 09:21:57 UTC
List:
ruby-core #78451
Issue #12753 has been updated by Shugo Maeda. Shugo Maeda wrote: > IBM InfoSphere and MS FoxPro have BITTEST(), but its second argument is the bit position > to be tested. > > http://www.ibm.com/support/knowledgecenter/SSZJPZ_11.3.0/com.ibm.swg.im.iis.ds.basic.doc/topics/r_dsbasic_BITTEST_function.html > https://msdn.microsoft.com/en-us/library/aa977348(v=vs.71).aspx > > This behavior seems to fit the name bittest, compared to the proposed one. I didn't mean to propose this behavior. I just meant to point out that `bittest?` may not be suitable for the proposed behavior. ---------------------------------------- Feature #12753: Useful operator to check bit-flag is true or false https://bugs.ruby-lang.org/issues/12753#change-61822 * Author: Satoshi TAGOMORI * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Ruby's 0 is truthy value. It's useful for many cases, but it's confusing and I made many bugs when I'm writing code to handle binary data, because my thought is almost same with one to write C code in such situation. ```ruby n = get_integer_value if n & 0b10100000 # code for the case when flag is true else # never comes here :( end ``` IMO it's very useful to have methods for such use-cases, like `#and?` and `#xor?` (`#or?` looks not so useful... I can't imagine the use case of this operator, but it's better to have for consistency). ```ruby n = get_integer_value case when n.and?(0b10000000) # negative signed char when n.and?(0b01110000) # large positive else # small positive end ``` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>