public static double hamming(double left, double right) {
            double distance = 0;
            byte a = (byte) left;
            byte b = (byte) right;
            for (int i = 0; i < 8; i++) {
                byte bit = (byte) (1 << i);
                if ((a & bit) != (b & bit)) {
                    distance += 1;
                }
            }
            return distance;
        }
Factory of scalar Java functions.
The purpose of this is to embellish anonymous functions with a runtime type
such that they can be inspected and will return a parsable toString.

@author bratseth
vespajlib/src/main/java/com/yahoo/tensor/functions/ScalarFunctions.java