This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
K-buitin Floats do not provide any hooks to convert a specific bit pattern into a single precision or double precision floating point value. #2383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirement
We need the ability to do the conversion as shown in examples:
Commit:
Note
The available hooks like float2Int or int2Float converts between the float and its integer equivalent and hence not suitable.
From example 2, int2Float(4623156123728347136) gives 4.623156123728347136 e+18
Some peculiarities of exiting mpfr library support:
While creating the BigFloat using BigFLoat constrcutor, we need to pass the unbiased exponent (mint(e1...e8) - 127) as the callee expects that. This is more evident from
https://github.com/kframework/mpfr-java/blob/a24d33c7589e285e840eaaba74368581dc15ebb3/src/main/java/org/kframework/mpfr/BigFloat.java#L357
where exponent is compared with mc.minExponent(-126) and mc.MaxExponent(+127).
For zero, BigFloat constructor expects -127 as opposed to -126 (a special exponent used for +/- zero). Inside the constructor, its converted back to 126. This is used to easily distinguish =/- zero and sub normals value from others.
https://github.com/kframework/mpfr-java/blob/a24d33c7589e285e840eaaba74368581dc15ebb3/src/main/java/org/kframework/mpfr/BigFloat.java#L364
Please accept the request if it seems suitable to the k-developers.