What number in binary can only be represented as an approximation?

前端 未结 10 710
礼貌的吻别
礼貌的吻别 2021-01-16 12:10

In decimal (base 10), 1/3 can only be approximated to 0.33333 repeating.

What number is the equivalent in binary that can only be represented as an app

10条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-16 12:18

    The numbers that can be exactly represented in base 2 are the dyadic rationals. These are numbers that can be written in the form k/2^n for some integer k and whole number n. Any number that cannot be written in that form will have a non-terminating representation in base 2.

    However, you seem to be asking not about what numbers are representable in base 2, but rather what numbers are representable in some fixed floating-point type, such as float or double. This is a more subtle question; any number that is not a dyadic rational cannot be represented, but not all dyadic rationals can be represented either.

提交回复
热议问题