We have a rational number double. How do you know whether it's periodic or not? - Continuous (coupling) fragments



  • We're given. sound Number double♪ How do you know whether it's periodic or not?



  • "Inside." double kept in the computation system for reasons 2and because 10 = 2 * 5any number presented by the final binary fragment may also be at the end of the decimal place.

    Accordingly, starting at some point, the endless decimal recording of any number submitted by the type doublewill be composed exclusively of zeros, which fits the definition of infinite sequence with period 1. Therefore:

    bool is_periodic(double x) {
      return true;
    }
    

    But there's a nuance.: This does not include infinity and NaN. Since they are not substance numbers, I have not considered these cases.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2