public static int getLevelForXp(int xp)
	{
		if (xp < 0)
		{
			throw new IllegalArgumentException("XP (" + xp + ") must not be negative");
		}

		int low = 0;
		int high = XP_FOR_LEVEL.length - 1;

		while (low <= high)
		{
			int mid = low + (high - low) / 2;
			int xpForLevel = XP_FOR_LEVEL[mid];

			if (xp < xpForLevel)
			{
				high = mid - 1;
			}
			else if (xp > xpForLevel)
			{
				low = mid + 1;
			}
			else
			{
				return mid + 1;
			}
		}

		return high + 1;
	}
@Test
	public void testGetLevelForXp()
	{
		int level = Experience.getLevelForXp(XP_FOR_99);
		assertEquals(99, level);

		level = Experience.getLevelForXp(XP_FOR_99 - 1);
		assertEquals(98, level);

		level = Experience.getLevelForXp(XP_FOR_126);
		assertEquals(126, level);

		level = Experience.getLevelForXp(XP_FOR_126 - 1);
		assertEquals(125, level);

		level = Experience.getLevelForXp(Integer.MAX_VALUE);
		assertEquals(126, level);

		level = Experience.getLevelForXp(0);
		assertEquals(1, level);
	}