kframework / k-legacy

The K tools (deprecated, see README)
http://kframework.org
Other
146 stars 61 forks source link

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 opened 6 years ago

sdasgup3 commented 6 years ago

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

Please accept the request if it seems suitable to the k-developers.

kframework-bot commented 6 years ago

Can one of the admins verify this patch?

daejunpark commented 6 years ago

Jenkins: ok to test