Created
January 4, 2015 07:28
-
-
Save devkato/5e7ae3097df0e5c7378e to your computer and use it in GitHub Desktop.
バイナリデータを作成する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = 100000 | |
f = open("./bin.#{N}.dat", 'w') | |
result = [0, 0] | |
1.upto(N) do |i| | |
ret = rand() > 0.5 ? 1 : 0 | |
result[ret] += 1 | |
f.write ret | |
end | |
result.each.with_index do |r, i| | |
puts "#{i} : #{r}" | |
end | |
f.flush | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0と1のビット数も表示するように(後で確認するため)