Java Distance Calculate distance(int first, int second)

Here you can find the source of distance(int first, int second)

Description

distance

License

Open Source License

Declaration

public static int distance(int first, int second) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int distance(int first, int second) {
        return NumberOfSetBits(first ^ second);
    }/*ww w  .jav  a 2 s.  c o m*/

    public static int NumberOfSetBits(int i) {
        i = i - ((i >>> 1) & 0x55555555);
        i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
        return (((i + (i >>> 4)) & 0x0F0F0F0F) * 0x01010101) >>> 24;
    }
}

Related

  1. distance(float x1, float y1, float x2, float y2)
  2. distance(float x1, float y1, float x2, float y2)
  3. distance(float[] p1, float[] p2)
  4. distance(float[] values1, float[] values2)
  5. distance(int ax, int ay, int bx, int by)
  6. distance(int fx, int fy, int sx, int sy)
  7. distance(int one, int two)
  8. distance(int px, int py, int x1, int y1, int x2, int y2)
  9. distance(int q1, int r1, int q2, int r2)