I am dealing with sums and substractions of large and small numbers in Matlab and I would like to estimate the exponent $e$ of the representation of the number in the computer which is in the form
$x = (-1)^{s} 2^e \ 1.f,$
in order to estimate the rounding error commited while storing it without having to manually pass it to binary representation.
Excerpt of facts from https://mathworks.com/help/matlab/ref/log2.html
returns a pair of real and integer number (or arrays of it if
Xis an array)For real
X, the pairE,Fsatisfies the equationX = F.*2.^E.Eis integer,Freal, usually in the range0.5 <= abs(F) < 1.This function corresponds to the ANSI® C function
frexp()and the IEEE floating-point standard functionlogb().Note however that as
(1.ddd)_2 = 2 * (0.1ddd)_2, the result you are looking for isE-1. (Which may be irrelevant, as you want to compare sizes.)