I am trying to parse a file containing some floating point test vectors in MATLAB.
Here is part of the file:
b32+ +1.7FFFFFP127 -1.7FFFFFP127 +0.0P0
b32+ +1.000000P0 -1.6D0976P9 -1.6CC976P9
b32+ +1.000000P-126 -1.000000P-126 +0.0P0
b32+ -1.7FFFFFP127 +1.7FFFFFP127 +0.0P0
b32- -1.7FFFFFP127 -1.7FFFFFP127 +0.0P0
b32- +1.000000P0 -1.000000P0 +1.000000P1
b32- -1.7C3AB6P14 +1.000000P0 -1.7C3CB6P14
b32- +1.2F0948P14 +1.000000P0 +1.2F0748P14
b32- -1.000000P-126 +1.000000P-126 -1.000000P-125
b32- +1.000000P-126 +1.000000P-126 +0.0P0
b32- -1.000000P-126 +1.0410ADP-103 -1.0410AEP-103
b32- +1.7FFFFFP127 +1.7FFFFFP127 +0.0P0
b32* +1.12D2C6P92 -1.000000P0 -1.12D2C6P92
b32* +1.7FFFFFP127 -1.000000P0 -1.7FFFFFP127
b32* -1.7FFFFFP127 +1.000000P0 -1.7FFFFFP127
b32* -1.5FEA32P-51 +1.000000P0 -1.5FEA32P-51
b32* -1.000000P-126 +1.000000P0 -1.000000P-126
b32* -1.000000P0 +1.000000P0 -1.000000P0
b32* +1.000000P0 +1.000000P0 +1.000000P0
b32* +1.000000P-126 +1.000000P0 +1.000000P-126
b32* +1.000000P-126 +1.7FFFFFP127 +1.7FFFFFP1
Basically I don't know how to parse this file because of the mixed data type.
There are three possible floating point operations shown in this file (addition: b32+, subtraction: b32-, and multiplication: b32*). The first two numbers are the operands and the last number is the result.
I want to format the numbers in 32-bit floating point format afterwards (which I could figure out probably). The issue is that I don't know how to get things like 'b32+', and then the numbers into variables in order to convert them into standard floating point format.
I plan to implement an algorithm for the numbers where it looks at the sign (+/-) and sets the sign bit based upon that. Looks at the hex between the '.' and the 'P' and sets that as the significand. Then take the number after the P as the unbiased exponent. Then I plan to repeat this procedure for the other numbers.
Thank you!