Arithmetic precision with doubles in Matlab

前端 未结 3 1064
礼貌的吻别
礼貌的吻别 2021-01-19 02:18

I am having a bit of trouble understanding how the precision of these doubles affects the outcome of arithmetic operations in Matlab. I thought that since both a & b are

3条回答
  •  借酒劲吻你
    2021-01-19 02:27

    "Floating" point means just that--the precision is relative to the scale of the number itself.

    In the specific example you gave, 1.22e-45 can be represented alone because the exponent can be adjusted to represent 10^-45, or approximately 2^-150.

    On the other hand, 1.0 is represented in binary with scale 2^0 (i.e., 1).

    To add these two values, you need to align their decimal points (er...binary points), meaning that all of the precision of 1.22e-45 is shifted 150-odd bits to the right.

    Of course, IEEE double precision floating point values only have 53 bits of mantissa (precision), meaning that at the scale of 1.0, 1.22e-45 is effectively zero.

提交回复
热议问题