Search code examples
matlabexponentmantissa

calculate mantissa and exponent of scientific number in matlab


I want to find mantissa and exponent of a number in mat lab. Is there a function or way to calculate them?

for example when the number is 0.0005 this function returns 5 for mantissa and -4 for exponent

thank you


Solution

  • The exponent can be given by :

    x= 0.0005;
    exponent=floor(log10(x));
    

    and the coefficient (I refuse to call it mantissa, because it disagrees with common definition).

    coeff=x/10^exponent;