/** * Converts a byte array with 4 elements to a double. Used to put doubles into a byte[] payload in a convenient * and fast way by shifting without using streams (which is kind of slow). Use * {@link net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double)} to encode. Note that there is a loss * in precision as the double is converted to a float in the course of conversion. * * @param data the input byte array * @return the resulting float * @see net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double) */ public static double toDouble(byte[] data) { return Double.longBitsToDouble(toLong(data)); }
/** * Converts a byte array with 4 elements to a double. Used to put doubles into a byte[] payload in a convenient * and fast way by shifting without using streams (which is kind of slow). Use * {@link net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double)} to encode. Note that there is a loss * in precision as the double is converted to a float in the course of conversion. * * @param data the input byte array * @return the resulting float * @see net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double) */ public static double toDouble(byte[] data) { return Double.longBitsToDouble(toLong(data)); }
/** * Converts a byte array with 4 elements to a double. Used to put doubles into a byte[] payload in a convenient * and fast way by shifting without using streams (which is kind of slow). Use * {@link net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double)} to encode. Note that there is a loss * in precision as the double is converted to a float in the course of conversion. * * @param data the input byte array * @return the resulting float * @see net.semanticmetadata.lire.utils.SerializationUtils#toBytes(double) */ public static double toDouble(byte[] data) { return Double.longBitsToDouble(toLong(data)); }