Floating Point precision, array out-of-bounds, differences between debug and release running, debugging under release

Source: Internet
Author: User

Vs2005 SP1

XP SP3

 

One Value in the program may be infinitely infinite, resulting in super deformation of the entire model. Later, we guessed that the radius value of the tree model was too large.

In this case, only when the program runs in release can it be wrong. In other cases, it will not be wrong,

In this way, debugging is impossible under release, and the value of the variable cannot be seen. You can only guess and view the value in a text file.

 

Problems involved: floating point precision, array out-of-bounds, differences between debug and release running,

 

Floating Point precision:

The precision of a computer is limited. A floating point may be 0.999998. in a computer, it may be 1,

However, if we compare it to 1 when making a judgment, the conditional judgment we get is smaller than 1, so there will be problems.

 

In some areas with high precision requirements, we can correct these calculated values,

Example: If (FABS (x-1.0f) <1e-6) x = 1.0

 

Array out-of-bounds:

The code at that time was float temppoint [1000] [2]; The application for one thousand bits actually only used 50 bits, while the 51st bits were not initialized,

Even if you want to initialize it at the time, you do not know which value is suitable for initialization at the time. As a result, the subsequent code accesses the 51st-bit value, resulting in a serious error.

This error will be reported only when the release runs directly, but it will not be wrong during debugging,

It may be that the compiler sets a default value for uninitialized values during debugging, depending on the differences between debug and release.

It is best to apply for an array of the number of BITs, or float temppoint [] [2];, and assign a value to the number of bits to be used.

Code out of bounds at that time:

For (k = 0; k <m_bz.m_number-1; k ++)
{
If (x> = m_bz.temppoint [k] [0] & x <= m_bz.temppoint [k + 1] [0])
Break;
}
If none of the above Code has a break, the value of K is equal to m_bz.m_number,

When the following code accesses m_bz.temppoint [m_bz.m_number] [0], an exception value may be accessed.

This is to apply for 1000 bits and only use the first 50 bits. When you access 51st bits, there will be problems. Of course, if you apply for only 50 bits at the beginning,

Also, start without debugging in release does not occur.

 

Debugging under release

The start without debugging error occurs during release. We output it to a text file to view the value of the variable.

Related Article

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.