I need to translate a code from matlab to fortran 90. What is the best way to implement an equivalent fortran code for the matlab log2 function that dissect floating-point numbers into exponent and mantissa. I need to compute E and F that are described in the matlab documentation :
"[F,E] = log2(X) returns arrays F and E. Argument F is an array of real values, usually in the range 0.5 <= abs(F) < 1. For real X, F satisfies the equation: X = F.*2.^E. Argument E is an array of integers that, for real X, satisfy the equation: X = F.*2.^E."
The Fortran standard has EXPONENT and FRACTION intrinsics that do this dissection. They are elemental, so if you pass them an array you get an array back.