Hi,
I am currently validating a algorithm on a C2000 FPU platform.
For this I compare results from Matlab and C2000 FPU target.
All processing are done in Floating single precision (singe in Matlab).
As of today, results are matching perfectly (binary comparison of the Floating single precision results).
However for "sqrt" function results does not match.
The difference comes from the "estimate of the inverse square root of x".
On the C200 target it is done with the instruction: EISQRTF32
On Matlab, I am calling a custom function to calculate the Estimate.
I am using one based on the famous : 5f3759df
Find below an example:
Find the estimate of x equal to x = 0.0003424387
1) With TI:
x= 0.0003424387
R0=x
EISQRTF32 R1H, R0H
R0= 0x39b38958 Note: R0 = 0.0003424387
R1= 0x42580000
2) With 5f3759df solution:
x= 0.0003424387
int i = *(int*)&x; // convert to binary integer -----> i = 968067416 = 0x39b38958
i = (i >> 1) -----> i = = 0x1cd9c4ac
i = 0x5f3759df - i; // the smart trick -----> i = 968067416 = 0x425d9533
x = *(float*)&i; // convert binary back to decimal
So :
TI result: 0x42580000
Other: 0x425d9533
Could you please indicate to me what is behind the EISQRTF32 instruction ?
Thanks and best regards,
Mathieu