@Test public void testHypotenuse() throws Exception { Random random = new Random(); for (int i = 0; i < TRIES; i++) { double x = random.nextDouble(); double y = random.nextDouble(); double h = Math.hypot(x, y); BigDecimal decimalX = BigDecimal.valueOf(x); BigDecimal decimalY = BigDecimal.valueOf(y); assertEquals(BigMath.hypot(x, y, CONTEXT).doubleValue() / h, 1, DBL_TOLERANCE); assertEquals(BigMath.hypot(decimalX, decimalY, CONTEXT).doubleValue() / h, 1, DBL_TOLERANCE); } }