[ruby-core:78389] Re: Improving Ruby Bitwise Operations
From:
Ferdinand Rosario <ferdinandrosario@...>
Date:
2016-11-27 07:11:25 UTC
List:
ruby-core #78389
I believe https://bugs.ruby-lang.org/ would be the right place to propose any ideas and get feedback directly from the core developers. *Best regards*, Ferdinand Rosario A Mobile : +91 8939939022 Twitter : @Ferdy_Rosario Skype : ferdinand.rosario LinkedIn: https://www.linkedin.com/in/ferdinandrosario GitHub : https://github.com/ferdinandrosario On 27 November 2016 at 01:01, RRRoy BBBean <rrroybbbean@gmail.com> wrote: > There is a ruby gem for bitwise operations, by Kenn Ejima, although it has > not been updated in 4 years. > > https://rubygems.org/gems/bitwise > https://github.com/kenn/bitwise > > I believe that the better approach for Ruby Bitwise Operations is to > "dust-off" this "bitwise" gem and add whatever functionality is needed. > That might include a ".mask" method, which returns true (if any resulting > bit is 1) or false (if all resulting bits are 0). Such a method would > bridge bitwise operations and Ruby's true/false. > > I further believe that having zero (integer, real, complex) be truthy is > the correct behavior, which Ruby already implements. > > Note that Ruby currently provides ".zero?" and ".nonzero?" methods for > numeric types. Although the return values are inconsistent between Integer, > Real and Complex, they do return values which are behave correctly (as > truthy or falsey). > > BEGIN CRITICAL > If anything needs to be changed in the Ruby core, it is to make the > results of ".zero?" and ".nonzero?" be consistently either true or false > for all numeric values. Such a change would nicely map bitwise operations > to Ruby true and false. > END CRITICAL > > > Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core> > Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>