91

I'm using the new Android Marshmallow SDK and the method FloatMath.sqrt() is gone. What should I use now?

0

1 Answer 1

245

The documentations say this:

Historically these methods were faster than the equivalent double-based java.lang.Math methods. On versions of Android with a JIT they became slower and have since been re-implemented to wrap calls to java.lang.Math. java.lang.Math should be used in preference.

All methods were removed from the public API in version 23.

@deprecated Use java.lang.Math instead.

This means the solution is to use the Math class:

(float)Math.sqrt(...)
Sign up to request clarification or add additional context in comments.

3 Comments

Ok, but what if it is referenced from a library, and Proguard is complaining?
I patched that library since I had it as part of my project. However you can implement a wrapper by your own, where you call the existing method.
I am migrating an old Android Project and found this. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.