public TolerantFloatComparison isWithin(float tolerance) {
    return new TolerantFloatComparison() {
      @Override
      public void of(float expected) {
        Float actual = FloatSubject.this.actual;
        checkNotNull(
            actual, "actual value cannot be null. tolerance=%s expected=%s", tolerance, expected);
        checkTolerance(tolerance);

        if (!equalWithinTolerance(actual, expected, tolerance)) {
          failWithoutActual(
              fact("expected", floatToString(expected)),
              butWas(),
              fact("outside tolerance", floatToString(tolerance)));
        }
      }
    };
  }
@Test
  public void isWithinZeroTolerance() {
    float max = Float.MAX_VALUE;
    assertThat(max).isWithin(0.0f).of(max);
    assertThat(NEARLY_MAX).isWithin(0.0f).of(NEARLY_MAX);
    assertThatIsWithinFails(max, 0.0f, NEARLY_MAX);
    assertThatIsWithinFails(NEARLY_MAX, 0.0f, max);

    float negativeMax = -1.0f * Float.MAX_VALUE;
    assertThat(negativeMax).isWithin(0.0f).of(negativeMax);
    assertThat(NEGATIVE_NEARLY_MAX).isWithin(0.0f).of(NEGATIVE_NEARLY_MAX);
    assertThatIsWithinFails(negativeMax, 0.0f, NEGATIVE_NEARLY_MAX);
    assertThatIsWithinFails(NEGATIVE_NEARLY_MAX, 0.0f, negativeMax);

    float min = Float.MIN_VALUE;
    assertThat(min).isWithin(0.0f).of(min);
    assertThat(JUST_OVER_MIN).isWithin(0.0f).of(JUST_OVER_MIN);
    assertThatIsWithinFails(min, 0.0f, JUST_OVER_MIN);
    assertThatIsWithinFails(JUST_OVER_MIN, 0.0f, min);

    float negativeMin = -1.0f * Float.MIN_VALUE;
    assertThat(negativeMin).isWithin(0.0f).of(negativeMin);
    assertThat(JUST_UNDER_NEGATIVE_MIN).isWithin(0.0f).of(JUST_UNDER_NEGATIVE_MIN);
    assertThatIsWithinFails(negativeMin, 0.0f, JUST_UNDER_NEGATIVE_MIN);
    assertThatIsWithinFails(JUST_UNDER_NEGATIVE_MIN, 0.0f, negativeMin);
  }