public long getLong(int index) { short val = storage[index]; return (long) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public char getChar(int index) { short val = storage[index]; return (char) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public int getInt(int index) { short val = storage[index]; return (int) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public float getFloat(int index) { short val = storage[index]; return (float) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public int getInt(Index i) { short val = storage[i.currentElement()]; return (unsigned ? DataType.unsignedShortToInt(val) : val); }
public double getDouble(Index i) { short val = storage[i.currentElement()]; return (double) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public long getLong(Index i) { short val = storage[i.currentElement()]; return (long) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public float getFloat(int index) { short val = storage[index]; return (float) (isUnsigned() ? DataType.unsignedShortToInt(val) : val); }
public float getFloat(Index i) { short val = storage[i.currentElement()]; return (float) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public char getChar(Index i) { short val = storage[i.currentElement()]; return (char) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public double getDouble(Index i) { short val = storage[i.currentElement()]; return (double) (unsigned ? DataType.unsignedShortToInt(val) : val); }
public double convertScaleOffsetMissing(short vals) { if (!hasScaleOffset) return useNaNs && isMissing((double) vals) ? Double.NaN : (double) vals; double convertedValue; if (isUnsigned) convertedValue = scale * DataType.unsignedShortToInt(vals) + offset; else convertedValue = scale * vals + offset; return useNaNs && isMissing(convertedValue) ? Double.NaN : convertedValue; }
public long getLong(Index i) { short val = storage[i.currentElement()]; return (long) (isUnsigned() ? DataType.unsignedShortToInt(val) : val); }
public int getInt(Index i) { short val = storage[i.currentElement()]; return (isUnsigned() ? DataType.unsignedShortToInt(val) : val); }
public double convertScaleOffsetMissing(short vals) { if (!hasScaleOffset) return useNaNs && isMissing((double) vals) ? Double.NaN : (double) vals; double convertedValue; if (isUnsigned) convertedValue = scale * DataType.unsignedShortToInt(vals) + offset; else convertedValue = scale * vals + offset; return useNaNs && isMissing(convertedValue) ? Double.NaN : convertedValue; }
public float getFloat(Index i) { short val = storage[i.currentElement()]; return (float) (isUnsigned() ? DataType.unsignedShortToInt(val) : val); }
public static void main(String[] args) { System.out.printf("byte == convertSignedByte == convertSignedByte2 == hex%n"); for (int i=125; i<256;i++) { byte b = (byte) i; System.out.printf("%d == %d == %d == %s%n", b, convertSignedByte(b), convertSignedByte2(b), Long.toHexString((long) i)); assert convertSignedByte(b) == convertSignedByte2(b) : convertSignedByte(b) +"!=" +convertSignedByte2(b); } int val = (int) DataType.unsignedByteToShort((byte) -200); int val2 = DataType.unsignedShortToInt((short) -200); System.out.printf("%d != %d%n", val, val2); }
private void convertScaleOffsetUnsignedShort(IndexIterator iterIn, IndexIterator iterOut) { boolean checkMissing = useNaNs && hasMissing(); while (iterIn.hasNext()) { short valb = iterIn.getShortNext(); double val = scale * DataType.unsignedShortToInt(valb) + offset; iterOut.setDoubleNext(checkMissing && isMissing_(val) ? Double.NaN : val); } }
private void convertScaleOffsetUnsignedShort(IndexIterator iterIn, IndexIterator iterOut) { boolean checkMissing = useNaNs && hasMissing(); while (iterIn.hasNext()) { short valb = iterIn.getShortNext(); double val = scale * DataType.unsignedShortToInt(valb) + offset; iterOut.setDoubleNext(checkMissing && isMissing_(val) ? Double.NaN : val); } }
public long convertScalarLong(int recnum, StructureMembers.Member m) { if (m.getDataType() == DataType.LONG || m.getDataType() == DataType.ULONG) return getScalarLong(recnum, m); if (m.getDataType() == DataType.INT) return (long) getScalarInt(recnum, m); if (m.getDataType() == DataType.UINT) return DataType.unsignedIntToLong( getScalarInt(recnum, m)); if (m.getDataType() == DataType.SHORT) return (long) getScalarShort(recnum, m); if (m.getDataType() == DataType.USHORT) return (long) DataType.unsignedShortToInt(getScalarShort(recnum, m)); if (m.getDataType() == DataType.BYTE) return (long) getScalarByte(recnum, m); if (m.getDataType() == DataType.UBYTE) return (long) DataType.unsignedByteToShort(getScalarByte(recnum, m)); Object o = getScalarObject(recnum, m); if (o instanceof Number) return ((Number) o).longValue(); throw new ForbiddenConversionException("Type is " + m.getDataType() + ", not convertible to int"); }