object_hexid incorrect

Discussion in 'Ruby' started by trans. (T. Onoma), Dec 1, 2004.

  1. Can anyone help me understand why these are not the same, and how to fix?

    class Object
    def object_hexid
    return "0x#{'%x'%(self.__id__)}"
    end
    end

    o.inspect
    => "#<Object:0x40335764>"

    o.object_hexid
    => "0x2019abb2"

    Thanks,
    T.
     
    trans. (T. Onoma), Dec 1, 2004
    #1
    1. Advertising

  2. trans.  (T. Onoma)

    ts Guest

    >>>>> "t" == trans (T Onoma) <> writes:

    t> => "#<Object:0x40335764>"

    t> o.object_hexid
    t> => "0x2019abb2"


    uln% ruby -e 'p "%x" % (2*0x2019abb2)'
    "40335764"
    uln%


    Guy Decoux
     
    ts, Dec 1, 2004
    #2
    1. Advertising

  3. trans.  (T. Onoma)

    Ruben Guest

    At Wed, 1 Dec 2004 23:48:48 +0900,
    trans. (T. Onoma) wrote:
    >
    > Can anyone help me understand why these are not the same, and how to fix?
    >
    > class Object
    > def object_hexid
    > return "0x#{'%x'%(self.__id__)}"
    > end
    > end
    >
    > o.inspect
    > => "#<Object:0x40335764>"
    >
    > o.object_hexid
    > => "0x2019abb2"
    >
    > Thanks,
    > T.


    Did you notice that (0x40335764 >> 1) == 0x2019abb2 ?

    Ruben
     
    Ruben, Dec 1, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-15?Q?Stefan_Schw=E4rzler?=

    what's incorrect ALIAS

    =?ISO-8859-15?Q?Stefan_Schw=E4rzler?=, Aug 3, 2005, in forum: VHDL
    Replies:
    1
    Views:
    479
    Jonathan Bromley
    Aug 4, 2005
  2. Dominique Vandensteen

    date format incorrect

    Dominique Vandensteen, Oct 23, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    470
    Bret Mulvey [MS]
    Oct 24, 2003
  3. John Hamm
    Replies:
    0
    Views:
    437
    John Hamm
    Nov 19, 2003
  4. =?Utf-8?B?TXIgV2l6YXJk?=
    Replies:
    2
    Views:
    1,696
    =?Utf-8?B?TXIgV2l6YXJk?=
    Jan 5, 2004
  5. Intransition

    #object_hexid

    Intransition, Apr 24, 2010, in forum: Ruby
    Replies:
    8
    Views:
    128
    Intransition
    Apr 25, 2010
Loading...

Share This Page