@Test public void testGetPercentageWithRangeOk() { assertEquals( 0, getPercentage( -1, 10 ) ); assertEquals( 0, getPercentage( 0, 10 ) ); assertEquals( 10, getPercentage( 1, 10 ) ); assertEquals( 20, getPercentage( 2, 10 ) ); assertEquals( 30, getPercentage( 3, 10 ) ); assertEquals( 40, getPercentage( 4, 10 ) ); assertEquals( 50, getPercentage( 5, 10 ) ); assertEquals( 60, getPercentage( 6, 10 ) ); assertEquals( 70, getPercentage( 7, 10 ) ); assertEquals( 80, getPercentage( 8, 10 ) ); assertEquals( 90, getPercentage( 9, 10 ) ); assertEquals( 100, getPercentage( 10, 10 ) ); assertEquals( 100, getPercentage( 11, 10 ) ); }
public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); }
NumberUtils { public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); } }
NumberUtils { public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); } private  NumberUtils(); }
NumberUtils { public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); } private  NumberUtils(); static int convertBitOrder( final int aValue, final int aBitCount, final BitOrder aBitOrder ); static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ); static Comparator<T> createNumberComparator( final boolean aSortAscending ); static int getBitIndex( final int aMaskValue ); static int getBitMask( final int aBitCount ); static int getPercentage( final int aValue, final int aRange ); static int getPercentage( final int aValue, final int aLowerBound, final int aUpperBound ); static int getPercentage( final long aValue, final long aRange ); static int getPercentage( final long aValue, final long aLowerBound, final long aUpperBound ); static boolean isPowerOfTwo( final int aValue ); static int packBytes( final int aValue ); static int reverseBits( final int aValue, final int aBitCount ); static int safeParseInt( final String aText ); static int safeParseInt( final String aText, final int aDefault ); static long safeParseLong( final String aText ); static long safeParseLong( final String aText, final long aDefault ); static int smartParseInt( final String aText ); static int smartParseInt( final String aText, final int aDefault ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition, final int aDefault ); }
NumberUtils { public static int getPercentage( final int aValue, final int aRange ) { double value = 0.0; if ( aRange != 0 ) { value = aValue * 100.0 / aRange; } return ( int )Math.max( 0.0, Math.min( 100.0, value ) ); } private  NumberUtils(); static int convertBitOrder( final int aValue, final int aBitCount, final BitOrder aBitOrder ); static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ); static Comparator<T> createNumberComparator( final boolean aSortAscending ); static int getBitIndex( final int aMaskValue ); static int getBitMask( final int aBitCount ); static int getPercentage( final int aValue, final int aRange ); static int getPercentage( final int aValue, final int aLowerBound, final int aUpperBound ); static int getPercentage( final long aValue, final long aRange ); static int getPercentage( final long aValue, final long aLowerBound, final long aUpperBound ); static boolean isPowerOfTwo( final int aValue ); static int packBytes( final int aValue ); static int reverseBits( final int aValue, final int aBitCount ); static int safeParseInt( final String aText ); static int safeParseInt( final String aText, final int aDefault ); static long safeParseLong( final String aText ); static long safeParseLong( final String aText, final long aDefault ); static int smartParseInt( final String aText ); static int smartParseInt( final String aText, final int aDefault ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition, final int aDefault );  }