bit-twiddle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e99fcc28158a3f2bd16c5e37e6cf4ad41761b1c
4
+ data.tar.gz: 5456fbb26c9f7ef7ac8bfd825ad06212ee99d757
5
+ SHA512:
6
+ metadata.gz: 26e0e2e18939a02a45e728360fa49befe19a42569e7669de1fa422f22c0c9611832bc069c7a91bf8782dda942814a319c6093981de8e9ea53aa1d68daae74a5e
7
+ data.tar.gz: a220ae44f99ea25432b8df8a3ff5ce7ec48781c9416775bff9088ff6243ebd6656c95273cc0cf2ead096e9e640bae7a48529077cb32304f9e0757d23f2630fc0
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ The program code in the 'bit-twiddle' repository (currently available at https://github.com/alexdowad/bit-twiddle) has been placed in the public domain by its author. You can do anything you want with it, anything at all. You can copy it, sell it, buy it, lease it, rent it out, put it in pawn, or use it as a down payment on a new truck. You can sing it out in the shower, or on a crowded bus. You can even inscribe it on a silk flag, and plant it on Kilimanjaro's snow-covered slopes. The possibilities are endless!
2
+
3
+ If you need a specific license, then make a copy of the code, solemnly declare that the copy belongs to you, and license it to yourself under any terms you desire.
@@ -0,0 +1,18 @@
1
+ #Fast bitwise operations for Ruby
2
+
3
+ Ruby has built-in implementations of the "workhorses" of bit manipulation: bitwise AND, OR, NOT, and XOR operations and bit shifts. This library adds more bitwise operations, which may be useful in implementing some algorithms. All the added operations are implemented in optimized C code. All operations on integers are implemented on both `Fixnum` and `Bignum`. Install this goodness with:
4
+
5
+ ```ruby
6
+ gem install bit-twiddle
7
+ ```
8
+
9
+ Here is what it offers:
10
+
11
+ ### Population count
12
+
13
+ "Popcount" or "population count" refers to the number of 1 bits in a binary number. For example, the popcount of 11 (binary 1011) is 3. Typically, Ruby programmers use goofy tricks like `num.to_s(2).count("1")` to compute this quantity. Don't bother with that nonsense. Just use the fastest native code which GCC can generate for your CPU architecture. (On x86 CPUs with SSE4, that is a single POPCNT instruction.) Like so:
14
+
15
+ ```
16
+ 7.popcount # => 3
17
+ 255.popcount # => 255
18
+ ```
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+ $CFLAGS << ' -Wall -Werror -O3 -march=native -mtune=native '
3
+ check_sizeof 'BDIGIT'
4
+ check_sizeof 'int'
5
+ check_sizeof 'long'
6
+ create_makefile 'bit_twiddling/bit_twiddling'
@@ -0,0 +1 @@
1
+ require 'bit_twiddling' # C extension
Binary file
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bit-twiddle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Dowad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: benchmark-ips
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.3'
69
+ description: Fast (native) bitwise operations for Ruby, in addition to the ones provided
70
+ by the standard library
71
+ email: alexinbeijing@gmail.com
72
+ executables: []
73
+ extensions:
74
+ - ext/bit_twiddling/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE
78
+ - README.md
79
+ - ext/bit_twiddling/extconf.rb
80
+ - lib/bit-twiddle.rb
81
+ - lib/bit_twiddling.so
82
+ homepage: http://github.com/alexdowad/bit-twiddle
83
+ licenses:
84
+ - None (Public Domain)
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.2.2
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Fast bitwise operations for Ruby
106
+ test_files: []
107
+ has_rdoc: