private boolean checkOverflowForUnsignedRational( Rational[] value ) { for( Rational v : value ) { if( v.getNumerator() < 0 || v.getDenominator() < 0 || v.getNumerator() > UNSIGNED_LONG_MAX || v.getDenominator() > UNSIGNED_LONG_MAX ) { return true; } } return false; }
private boolean checkOverflowForRational( Rational[] value ) { for( Rational v : value ) { if( v.getNumerator() < LONG_MIN || v.getDenominator() < LONG_MIN || v.getNumerator() > LONG_MAX || v.getDenominator() > LONG_MAX ) { return true; } } return false; }
private boolean checkOverflowForRational( Rational[] value ) { for( Rational v : value ) { if( v.getNumerator() < LONG_MIN || v.getDenominator() < LONG_MIN || v.getNumerator() > LONG_MAX || v.getDenominator() > LONG_MAX ) { return true; } } return false; }
private boolean checkOverflowForUnsignedRational( Rational[] value ) { for( Rational v : value ) { if( v.getNumerator() < 0 || v.getDenominator() < 0 || v.getNumerator() > UNSIGNED_LONG_MAX || v.getDenominator() > UNSIGNED_LONG_MAX ) { return true; } } return false; }
public OrderedDataOutputStream writeRational( Rational rational ) throws IOException { writeInt( (int) rational.getNumerator() ); writeInt( (int) rational.getDenominator() ); return this; }
public OrderedDataOutputStream writeRational( Rational rational ) throws IOException { writeInt( (int) rational.getNumerator() ); writeInt( (int) rational.getDenominator() ); return this; }
/** * Gets a long representation of the value. * * @param defaultValue value to return if there is no value or value is a * rational with a denominator of 0. * @return the tag's value as a long, or defaultValue if no representation * exists. */ public long forceGetValueAsLong( long defaultValue ) { long[] l = getValueAsLongs(); if( l != null && l.length >= 1 ) { return l[0]; } byte[] b = getValueAsBytes(); if( b != null && b.length >= 1 ) { return b[0]; } Rational[] r = getValueAsRationals(); if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) { return (long) r[0].toDouble(); } return defaultValue; }
/** * Gets a long representation of the value. * * @param defaultValue value to return if there is no value or value is a * rational with a denominator of 0. * @return the tag's value as a long, or defaultValue if no representation * exists. */ public long forceGetValueAsLong( long defaultValue ) { long[] l = getValueAsLongs(); if( l != null && l.length >= 1 ) { return l[0]; } byte[] b = getValueAsBytes(); if( b != null && b.length >= 1 ) { return b[0]; } Rational[] r = getValueAsRationals(); if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) { return (long) r[0].toDouble(); } return defaultValue; }