Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Come up with a more optimized solution for ieee754_float constraint #218

Open
popematt opened this issue Oct 11, 2022 · 2 comments
Open

Comments

@popematt
Copy link
Contributor

popematt commented Oct 11, 2022

I also suspect there's a fast generalizeable way to detect this from bits, using toRawBits() and bit twiddling.
I looked at Float Toy and the manipulations of this gist, but ran out of energy and enthusiasm for reasoning through the corner cases.

I suspect that detecting "out of bounds" values in the double precision bit field is likely easier than straight conversion.

Originally posted by @jobarr-amzn in #213 (comment)

Taking b as the number of bits in the floating point representation, the current solution requires O(2^b) of auxiliary storage for storing the precision intervals and O(2^b) operations to compare the floating point number against the precision intervals.

A "more optimized" solution would ideally require no table of precision intervals, and would run in some constant number of operations.

@popematt popematt changed the title See if it's possible to improve performance of ieee754_float constraint Come up with a more optimized solution for ieee754_float constraint Oct 11, 2022
@jobarr-amzn
Copy link

Looks like we might be able to borrow conversion logic from a future JDK version: https://github.com/openjdk/jdk/blob/07946aa49c97c93bd11675a9b0b90d07c83f2a94/src/java.base/share/classes/java/lang/Float.java#L980 ?

@jobarr-amzn
Copy link

Or perhaps we could work with android.util.Half, or Half from kotlin-math...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants