tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Jodd > Commons > How to create Hash from Floats

How to create Hash from Floats 

Jodd is an open-source java library with lot of reusable components and feature rich utilities. This requires the library jodd-3.3.2.jar to be in classpath. The following example shows how to use HashCode.hash() API. It calculates the hash code from the given floats.

File Name  :  
com/bethecoder/tutorials/jodd/hash/HashFromFloatsTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.jodd.hash;

import jodd.util.HashCode;

public class HashFromFloatsTest {

  /**
   @param args
   */
  public static void main(String[] args) {

    int seed = HashCode.SEED;
    int hashCode = HashCode.hash(seed, 1234.56f);
    System.out.println(hashCode);

    hashCode = HashCode.hashFloatArray(seed, 11.11f22.22f33.33f);
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new float [] { 1.23f,  45.6f7.89f });
    System.out.println(hashCode);
    
    hashCode = HashCode.hash(seed, new float [] { 2.3f,  4.5f6.789f });
    System.out.println(hashCode);
  }

}
   

It gives the following output,
1150970605
1683330471
72243964
1021034897



 
  


  
bl  br