Videos
The method you use has the following signature: static double pow(double a, double b). This means, the parameters will automatically be cast to double and it's return value is also a double.
There is no overload for a long return value so you will either have to cast the result manually to long with this: n - (long)Math.pow(10, l-1).
Edit: or use another solution like the BigInteger one, but be aware that BigInteger (and BigDecimal) only accepts int as exponent, not long and not BigInteger.
Math.pow won't guarantee 100% accuracy on large integer values beyond some threshold (see this question for details) because floats and doubles cannot accurately represent all integers supported by the long type. Therefore, I would recommend you to use a BigInteger, which also has a pow function and will give you correctly formatted results out of the box.