Abstract: Division by zero in interval Division

Source: Internet
Author: User

We are required to solve the problem of division by zero in the interval division operation in column 2.10.

When talking about Ben bitdiddle, a professional programmer, after reading Alyssa's work, he raised the question of Division from zero. Everyone should pay attention to the person named Ben, who will keep appearing next to him, as long as this person mentioned something, it is generally right. His role is positioned as a computer cool, but it is the kind of cool people that can often be seen in the office, and there are more cool people in the future.

Division by zero for Interval operations is easy to handle. You only need to determine whether the divisor is zero. If the divisor is zero, an error is returned. For an interval, the so-called zero is that the interval spans 0, and the start point is negative, and the end point is positive.

After understanding this, it is easy to write code:

(define (div-interval x y)  (if (< (* (upper-bound y) (lower-bound y)) 0)      (error "Div 0:" y))  (mul-interval x(make-interval (/ 1.0 (upper-bound y))       (/ 1.0 (lower-bound y)))))

Okay. The problem solving is over.

Abstract: Division by zero in interval Division

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.