This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Open
sdasgup3
wants to merge
10
commits into
kframework:master
Choose a base branch
from
sdasgup3:machineFloatSupport
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ttern into a single precision or double precision floating point value. Requirement: We need the ability to do the conversion as shown in examples: Example 1: bit-vector: 32' 01000001 01000110 00000000 00000000 === MInt(32, 1095106560) convert to or from Float(single precision): 12.375f. Example 2: bit-vector: 64' 0b0100000000101000110000000000000000000000000000000000000000000000 === MInt(64, 4623156123728347136) convert to or from Float(single precision): 12.375d. Commit: Provides two following two hooks: 1. float2mint(Float F, Int W): Converts a float point value F(single or double precision) to a BitVector or MInt of bitwidth W. 2. mint2float(MInt MI, Int Precision, Int Exponent): Converts a Bitvector or MInt to an single or double precision float point value. The hooks are tested extensively using corner cases. 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: 1. 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). 2. 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
Can one of the admins verify this patch? |
Jenkins: ok to test |
…aviour is to warn with an exception thrown, but the mvn -e clean verify make the wanr an error
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.