/** * Read a {@code double} value from the buffer {@code buff}. */ public double decodeDouble(byte[] buff, int offset) { double val = Bytes.toDouble(buff, offset); return val; }
/** * @param bytes byte array * @return Return double made from passed bytes. */ public static double toDouble(final byte [] bytes) { return toDouble(bytes, 0); }
private static double decodeUnsignedDouble(byte[] b, int o) { checkForSufficientLength(b, o, Bytes.SIZEOF_DOUBLE); double v = Bytes.toDouble(b, o); if (v < 0) { throw new RuntimeException(); } return v; }
public void testToDouble() throws Exception { double [] doubles = {Double.MIN_VALUE, Double.MAX_VALUE}; for (int i = 0; i < doubles.length; i++) { byte [] b = Bytes.toBytes(doubles[i]); assertEquals(doubles[i], Bytes.toDouble(b), 0.0); byte [] b2 = bytesWithOffset(b); assertEquals(doubles[i], Bytes.toDouble(b2, 1), 0.0); } }
return Bytes.toFloat(value); case 7: return Bytes.toDouble(value); case 8: return Bytes.toBoolean(value);
@Override public Double decode(PositionedByteRange src) { double val = Bytes.toDouble(src.getBytes(), src.getOffset() + src.getPosition()); skip(src); return val; }
/** * Converts the value bytes of the given cell into a double value * @param cell * @return value as double */ public static double getValueAsDouble(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toDouble(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toDouble(cell.getValueArray(), cell.getValueOffset()); }
res = Bytes.toDouble(bytes);
res = Bytes.toFloat(bytes); } else if (Double.class == clazz || double.class == clazz) { res = Bytes.toDouble(bytes); } else if (Byte.class == clazz || byte.class == clazz) { res = bytes[0];
public void testToStringBinary_toBytesBinary_Reversable() throws Exception { String bytes = Bytes.toStringBinary(Bytes.toBytes(2.17)); assertEquals(2.17, Bytes.toDouble(Bytes.toBytesBinary(bytes)), 0); }
@Override public double decodeDouble(byte[] b, int o, ColumnModifier columnModifier) { if (columnModifier != null) { b = columnModifier.apply(b, o, new byte[Bytes.SIZEOF_DOUBLE], 0, Bytes.SIZEOF_DOUBLE); } double v = Bytes.toDouble(b, o); if (v < 0) { throw new IllegalDataException(); } return v; } }
@Override public double decodeDouble(byte[] b, int o, SortOrder sortOrder) { Preconditions.checkNotNull(sortOrder); checkForSufficientLength(b, o, Bytes.SIZEOF_DOUBLE); if (sortOrder == SortOrder.DESC) { b = SortOrder.invert(b, o, new byte[Bytes.SIZEOF_DOUBLE], 0, Bytes.SIZEOF_DOUBLE); o = 0; } double v = Bytes.toDouble(b, o); if (v < 0) { throw newIllegalDataException(); } return v; } }
return Bytes.toDouble(b);
return Bytes.toDouble(b);
/** * @param bytes byte array * @return Return double made from passed bytes. */ public static double toDouble(final byte [] bytes) { return toDouble(bytes, 0); }
/** * @param bytes byte array * @return Return double made from passed bytes. */ public static double toDouble(final byte [] bytes) { return toDouble(bytes, 0); }
/** * Read a {@code double} value from the buffer {@code buff}. */ public double decodeDouble(byte[] buff, int offset) { double val = Bytes.toDouble(buff, offset); return val; }
public void testToDouble() throws Exception { double [] doubles = {Double.MIN_VALUE, Double.MAX_VALUE}; for (int i = 0; i < doubles.length; i++) { byte [] b = Bytes.toBytes(doubles[i]); assertEquals(doubles[i], Bytes.toDouble(b), 0.0); byte [] b2 = bytesWithOffset(b); assertEquals(doubles[i], Bytes.toDouble(b2, 1), 0.0); } }
@Override public Double decode(PositionedByteRange src) { double val = Bytes.toDouble(src.getBytes(), src.getOffset() + src.getPosition()); skip(src); return val; }
/** * Converts the value bytes of the given cell into a double value * @param cell * @return value as double */ public static double getValueAsDouble(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toDouble(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toDouble(cell.getValueArray(), cell.getValueOffset()); }