Binary Operation in Ruby

V

Vu Nang Luc

Dear all,

I've tried Ruby for some time. The language is pretty nice but now I
need some operations with binary data. I tried but I still can not
find out what to use?

What I really need is:
a = 3;
b = ~a;
c = a >>; ......
and some some class to handle an array of bytes.

I think the ability to manage binary data is vital for any languge,
can you tell me which functions to use?

Sincerely,

VN Luc
 
R

rmagick

Dear all,

I've tried Ruby for some time. The language is pretty nice but now I
need some operations with binary data. I tried but I still can not
find out what to use?

What I really need is:
a = 3;
b = ~a;
c = a >>; ......
and some some class to handle an array of bytes.

I think the ability to manage binary data is vital for any languge,
can you tell me which functions to use?

Sincerely,

VNLuc

In Ruby we use the String class to hold bytes. Search this group's
archives for "binary file". Check out the Array#pack and String#unpack
methods.
 
V

Vu Nang Luc

(e-mail address removed) vi t:
In Ruby we use the String class to hold bytes. Search this group's
archives for "binary file". Check out the Array#pack and String#unpack
methods.

Thanks, that's quite useful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,311
Members
47,978
Latest member
ReneGibson

Latest Threads

Top