Created
May 27, 2014 18:41
-
-
Save sebyx07/909ef1f2aa6676191691 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
class Fixnum | |
def convert_base(to) | |
self.to_s(to).to_i | |
end | |
end | |
i=1 | |
puts ("Enter input:") | |
input = gets.chomp | |
input=input.to_i(10).convert_base(2) | |
puts ("Output:"), input | |
bit=Array.new(8) | |
#8 BIT REPRESENTATION | |
if input.convert_base(10)>0 | |
bit[0]=0 | |
else | |
bit[0]=1 | |
end | |
while(i<8) | |
bit.push input[i] | |
i += 1 | |
end | |
bit.each { |a| print a, "" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment