Hashcode of primitive types

Discussion in 'Java' started by Dimitri Pissarenko, Jan 29, 2004.

  1. Hello!

    What is the hashcode of int, double or float?

    TIA

    dap
     
    Dimitri Pissarenko, Jan 29, 2004
    #1
    1. Advertising

  2. Dimitri Pissarenko

    Adam Guest

    > Hello!
    >
    > What is the hashcode of int, double or float?


    Primitives don't have hashcodes.
    Objects do.

    Adam
     
    Adam, Jan 29, 2004
    #2
    1. Advertising

  3. "Dimitri Pissarenko" <> wrote in message
    news:...
    > Hello!
    >
    > What is the hashcode of int, double or float?


    convert to java.lang.Integer, java.lang.Double or java.lang.Float and call
    the hash member function.

    > TIA
    >
    > dap


    Tom
     
    TT \(Tom Tempelaere\), Jan 29, 2004
    #3
  4. Dimitri Pissarenko

    Alex Hunsley Guest

    TT (Tom Tempelaere) wrote:

    > "Dimitri Pissarenko" <> wrote in message
    > news:...
    >
    >>Hello!
    >>
    >>What is the hashcode of int, double or float?

    >
    >
    > convert to java.lang.Integer, java.lang.Double or java.lang.Float and call
    > the hash member function.
    >
    >


    For Integer, you may as well just the use the value of the int itself. I
    can't see any reason for any other mapping to be any better than this,
    and it's what Integer.hashCode() does anyway...

    alex
     
    Alex Hunsley, Jan 29, 2004
    #4
  5. (Dimitri Pissarenko) wrote:

    > Hello!
    >
    > What is the hashcode of int, double or float?


    42.

    (but that's a really bad hashcode)

    --
    No address munging in use. I like the smell of nuked accounts in the
    morning.
     
    Timo Kinnunen, Jan 29, 2004
    #5
  6. Dimitri Pissarenko

    Hylander Guest

    Timo Kinnunen <> wrote in message news:<Xns947FB90EEF07Etimokinnunenbigfootc@130.233.228.196>...
    > (Dimitri Pissarenko) wrote:
    >
    > > Hello!
    > >
    > > What is the hashcode of int, double or float?

    >
    > 42.
    >
    > (but that's a really bad hashcode)


    well for 3 its 34327891
    and for 4 its 43829091
    but for 5 its 5. (for some reason)

    HTH
     
    Hylander, Jan 29, 2004
    #6
    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-1?Q?S=F8ren_Bak?=

    Collections API for primitive types

    =?ISO-8859-1?Q?S=F8ren_Bak?=, Aug 27, 2003, in forum: Java
    Replies:
    0
    Views:
    421
    =?ISO-8859-1?Q?S=F8ren_Bak?=
    Aug 27, 2003
  2. munki
    Replies:
    5
    Views:
    3,137
    Michael Borgwardt
    Oct 8, 2003
  3. garfield
    Replies:
    3
    Views:
    502
    John C. Bollinger
    Oct 30, 2003
  4. Replies:
    7
    Views:
    627
    Victor Bazarov
    May 9, 2005
  5. Daniel Pitts
    Replies:
    7
    Views:
    518
Loading...

Share This Page