RangeUtils { public static float getFloatValueInRange(float fromRangeMin, float fromRangeMax, float toRangeMin, float toRangeMax, float fromRangeValue) { float oldRange = (fromRangeMax - fromRangeMin); float newRange = (toRangeMax - toRangeMin); return (((fromRangeValue - fromRangeMin) * newRange) / oldRange) + toRangeMin; }  static int getIntValueInRange(int fromRangeMin, int fromRangeMax, int toRangeMin,
      int toRangeMax, int fromRangeValue); static float getFloatValueInRange(float fromRangeMin, float fromRangeMax, float toRangeMin,
      float toRangeMax, float fromRangeValue);  }
@Test public void theValue50InTheOldRangeMustBe0_5OnTheNewRange(){ int fromMin = 0; int fromMax = 100; int toMin = 0; int toMax = 1; float result = RangeUtils.getFloatValueInRange(fromMin, fromMax, toMin, toMax, 50); Assert.assertTrue(result == 0.5f); }