public float getAsFloat ( int index ) { switch ( type ) { case TIFF_BYTE : return ( ( byte [ ] ) data ) [ index ] & 0xff ; case TIFF_SBYTE : return ( ( byte [ ] ) data ) [ index ] ; case TIFF_SHORT : return ( ( char [ ] ) data ) [ index ] & 0xffff ; case TIFF_SSHORT : return ( ( short [ ] ) data ) [ index ] ; case TIFF_SLONG : return ( ( int [ ] ) data ) [ index ] ; case TIFF_LONG : return ( ( long [ ] ) data ) [ index ] ; case TIFF_FLOAT : return ( ( float [ ] ) data ) [ index ] ; case TIFF_DOUBLE : return ( float ) ( ( double [ ] ) data ) [ index ] ; case TIFF_SRATIONAL : int [ ] ivalue = getAsSRational ( index ) ; return ( float ) ( ( double ) ivalue [ 0 ] / ivalue [ 1 ] ) ; case TIFF_RATIONAL : long [ ] lvalue = getAsRational ( index ) ; return ( float ) ( ( double ) lvalue [ 0 ] / lvalue [ 1 ] ) ; default : throw new ClassCastException ( ) ; } }
Returns data in any numerical format as a float . Data in TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated by dividing the numerator into the denominator using double - precision arithmetic and then truncating to single precision . Data in TIFF_SLONG TIFF_LONG or TIFF_DOUBLE format may suffer from truncation .