Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > & - FixNum - method doubt

Reply
Thread Tools

& - FixNum - method doubt

 
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Hi All,

irb> a=12
irb> a.methods

it contains & method

So I tried like ..
irb> 3&6
=> 2
irb> 3&7
=> 3
irb> 7&21
=> 5

I can't understand how it works. Anyone help me


Thanks,
P.Raveendran
http://raveendran.wordpress.com
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Randall Alexander
Guest
Posts: n/a
 
      03-21-2009
[Note: parts of this message were removed to make it a legal post.]

I am just learning Ruby but it looks like the binary intersection of the
true bits. In shorter terms a binary "and" command.
3&6=2
in binary
011&110=010

3&7=3
in binary
011&111=011

7&21=5
in binary
00111&10101=00101

Randy

On Sat, Mar 21, 2009 at 1:04 AM, jazzez ravi <> wrote:

> Hi All,
>
> irb> a=12
> irb> a.methods
>
> it contains & method
>
> So I tried like ..
> irb> 3&6
> => 2
> irb> 3&7
> => 3
> irb> 7&21
> => 5
>
> I can't understand how it works. Anyone help me
>
>
> Thanks,
> P.Raveendran
> http://raveendran.wordpress.com
> --
> Posted via http://www.ruby-forum.com/.
>
>



--
Randy
http://randallalexander-os.blogspot.com/
http://randallalexander-java.blogspot.com/
http://randallalexander-flex.blogspot.com/
http://randallalexander-ruby.blogspot.com/

 
Reply With Quote
 
 
 
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Randall Alexander wrote:
> I am just learning Ruby but it looks like the binary intersection of the
> true bits. In shorter terms a binary "and" command.
> 3&6=2
> in binary
> 011&110=010
>
> 3&7=3
> in binary
> 011&111=011
>
> 7&21=5
> in binary
> 00111&10101=00101
>
> Randy


Hi Randy,

Thank you very much for your quick reply.

Also i need help about these methods

+@
-@
=~

Thanks in Advance,
Thanks,
P.Raveendran
http://raveendran.wordpress.com
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Hi Randy,

And few more ..

+@
-@
=~
>>

[]
^
__id__
__send__

Waiting for your reply



Thanks in Advance,
Thanks,
P.Raveendran
http://raveendran.wordpress.com

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Leo
Guest
Posts: n/a
 
 
Reply With Quote
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Leo wrote:
>> And few more ..

>
> http://www.ruby-doc.org/core-1.9/classes/
> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html


Hi Leo,

Thanks for your reply.

I am using Ruby 1.86 so http://www.ruby-doc.org/core/ will help me.


Regards,
P.Raveendran
http://raveendran.wordpress.com
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Leo wrote:
>> And few more ..

>
> http://www.ruby-doc.org/core-1.9/classes/
> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html


Hi Leo,

http://www.ruby-doc.org/core-1.9/classes/Fixnum.html also I couldn't
find the methods like,

__id__
__send__
denominator

etc..,

Please help to me once again..


Regards,
P.Raveendran
http://raveendran.wordpress.com
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Christopher Dicely
Guest
Posts: n/a
 
      03-21-2009
2009/3/21 jazzez ravi <>:
> Leo wrote:
>>> And few more ..

>>
>> http://www.ruby-doc.org/core-1.9/classes/
>> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html

>
> Hi Leo,
>
> http://www.ruby-doc.org/core-1.9/classes/Fixnum.html also I couldn't
> find the methods like,
>
> __id__
> __send__
> denominator
>



Methods that appear for instances of a particular class may be defined
in ancestors of that class (or included modules, either of the class
or its ancestors), rather than than in the class itself. In this case
__id__ and __send__ are Kernel methods (probably documented under
Object, rather than Kernel) and denominator is, I think, defined in
Numeric.

 
Reply With Quote
 
jazzez ravi
Guest
Posts: n/a
 
      03-21-2009
Christopher Dicely wrote:
> 2009/3/21 jazzez ravi <>:
>>
>> __id__
>> __send__
>> denominator
>>

>
>
> Methods that appear for instances of a particular class may be defined
> in ancestors of that class (or included modules, either of the class
> or its ancestors), rather than than in the class itself. In this case
> __id__ and __send__ are Kernel methods (probably documented under
> Object, rather than Kernel) and denominator is, I think, defined in
> Numeric.


Hi christopher,

Yes. Finally I got exact solution.Thanks for your help.

Regards,
P.Raveendran
http://raveendran.wordpress.com
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
jazzez ravi
Guest
Posts: n/a
 
      03-30-2009
Hi All,

>> Methods that appear for instances of a particular class may be defined
>> in ancestors of that class (or included modules, either of the class
>> or its ancestors), rather than than in the class itself. In this case
>> __id__ and __send__ are Kernel methods (probably documented under
>> Object, rather than Kernel) and denominator is, I think, defined in
>> Numeric.


I spent more time to find the solution for all methods. So I created one
document which contains all the methods for that particular class.

Now it is available here

Fixnum:

http://raveendran.wordpress.com/2009...documentation/

String:

http://raveendran.wordpress.com/2009...documentation/


Regards,
P.Raveendran
http://raveendran.wordpress.com

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Float Arithmetic: Return A Fixnum When Float == Fixnum MaggotChild Ruby 6 12-02-2009 04:28 AM
private method - Fixnum (NoMethodError) salai Ruby 3 06-30-2009 03:13 PM
Why Fixnum===Fixnum is false? Heesob Park Ruby 5 05-14-2009 12:31 AM
Why there is not "replace" method for Fixnum? IƱaki Baz Castillo Ruby 9 05-03-2008 07:34 PM
doubt about doubt Bob Nelson C Programming 11 07-30-2006 08:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57