Floating Point Number rounding

Source: Internet
Author: User

In Chapter 2nd of "computer hardware technology basics", the problem of proximity rounding (even) in the Round-off control in Table 2-5 on the 39 page is not clear about it. I don't know what it means. Here is an example.

Answer:
The following text of the table is explained:
For example, if a valid number exceeds the specified number, the excess number is 1001, which is more than half of the specified digit (that is, 0.5), so the digit is 1. If the extra number is 0111, and it is less than half of the percentile, the extra number (truncation of the ending number and truncation of the end) will be removed. In special cases where the number is 1000 and the number is half the number of digits, if the number of digits is 0, the number of digits is reduced. If the number of digits is 1, the number of digits is 1, so that the number of digits is still 0 (even ).

Note that the numbers described here refer to binary numbers.

For example, you must keep the three digits after the decimal point.

For 1.0011001, the rounded value is 1.010 (remove the four extra digits and add 0.001)
For 1.0010111, the rounded value is 1.001 (remove the extra four digits)
For 1.0011000, the value after rounding is 1.010 (remove the four extra bits and add 0.001 to make the trim bits 0)

For 1.1001001, the rounded value is 1.101 (remove the four extra digits and add 0.001)
For 1.1000111, the rounded value is 1.100 (remove the extra four digits)
For 1.1001000, the value after rounding is 1.100 (remove the four extra digits and do not add them, because the trim bit is already 0)

For 1.01011, the rounded value is 1.011 (remove the remaining two digits and add 0.001)
For 1.01001, the rounded value is 1.010 (remove the remaining two digits)
For 1.01010, the rounded value is 1.010 (remove the remaining two digits without adding)

For 1.01111, the rounded value is 1.100 (remove the remaining two digits and add 0.001)
For 1.01101, the rounded value is 1.011 (remove the remaining two digits)
For 1.01110, the rounded value is 1.100 (remove the remaining two digits and add 0.001)

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.