Java Hash Code Calculate hashCode(double val)

Here you can find the source of hashCode(double val)

Description

Returns a hash code for the specified double value.

License

Open Source License

Declaration


public static int hashCode(double val) 

Method Source Code

//package com.java2s;
/**//  w  ww.  j  a  v a 2  s  .  co  m
 * The utillib library.
 * More information is available at http://www.jinchess.com/.
 * Copyright (C) 2002, 2003 Alexander Maryanovsky.
 * All rights reserved.
 *
 * The utillib library is free software; you can redistribute
 * it and/or modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * The utillib library is distributed in the hope that it will
 * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
 * General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with utillib library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
 */

public class Main {
    /**
     * Returns a hash code for the specified double value.
     */

    public static int hashCode(double val) {
        return hashCode(Double.doubleToLongBits(val));
    }

    /**
     * Returns a hash code for the specified long value.
     */

    public static int hashCode(long val) {
        return (int) (val ^ (val >>> 32));
    }

    /**
     * Returns a hash code for the combination of the two specified objects.
     */

    public static int hashCode(Object o1, Object o2) {
        int hash1 = (o1 == null ? 0 : o1.hashCode());
        int hash2 = (o2 == null ? 0 : o2.hashCode());
        return 37 * hash1 + hash2;
    }
}

Related

  1. hashCode(char[] array, int start, int end)
  2. hashCode(char[] array, int start, int end)
  3. hashCode(CharSequence seq)
  4. hashCode(double dbl)
  5. hashCode(double v)
  6. hashCode(final byte[] data)
  7. hashCode(final char[] text, final int textOffset, final int textLen)
  8. hashCode(final int i)
  9. hashCode(final int i)