How to calculate mantissa of 0.5
10 views (last 30 days)
Star Strider on 17 Sep 2021
I created a little utility function to calculate the mantissa and exponent of a floating-point number a while ago, for my own use.
Trying it here —
expstr = @(x) [x(:).*10.^ceil(-log10(abs(x(:)+(x==0)))) floor(log10(abs(x(:)+(x==0))))];
The mantissa is the first element and the exponent is the second element in each row.