public static int PerfectSquareRoot(int val) { int squareRoot = (int)FloatUtils.SquareRoot(val); if (squareRoot * squareRoot != val) { throw new Exception($"[{nameof(IntUtils)}] '{val}' has no perfect square-root"); } return(squareRoot); }
public static int?TryPerfectSquareRoot(int val) { int squareRoot = (int)FloatUtils.SquareRoot(val); if (squareRoot * squareRoot != val) { return(null); } return(squareRoot); }