Mathematical basis of the process of large numbers -- unfinished

Source: Internet
Author: User
Generally, the Linux kernel does not support floating-point operations. In the process of data processing, we often encounter the following embarrassment: the data bit length in the calculation process conflicts with the error in the calculation result. for example, for example, an expression like 102448/7*1024 can be expressed as follows in the kernel :...

Generally, the Linux kernel does not support floating-point operations. In the process of data processing, we often encounter the following embarrassment: the data bit length in the calculation process conflicts with the error in the calculation result.
Example: 102448/7*1024
Such expressions can be expressed as follows in the kernel:
Long result = 102448/7*1024;
Of course, as an actual operation, the literal constants in an expression are usually some variables. If the result has a cumulative effect, the above expression will produce a fatal error.
In mathematical expression, the value of 102448/7*1024 is 14986678.
The value of the expression result = 102448/7*1024 is 14986240.
Obviously, this error is huge. how can we adjust it?
We can resort to the mathematical equations:
{A/B * C} = [A/B * C + A % B * C/B]
We will verify:
Result = 102448/7*1024 + 102448% 7*1024/7;
Result = 14986240 + 438
Result = 14986678.
To be continued

Author: "www.475551408.qq.com"

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.