How to determine whether a float/double is a valid value

Source: Internet
Author: User

A few days ago, the game program exploded in the triangle collision test.

The result shows that D3DXIntersectTri returns a float (-1. # INF000) to me ).

I believe everyone is familiar with this value.

This value usually occurs when the divisor is 0, that is, the denominator is 0.

Like this:

Float a =. 7f;

Float B =. 0f;

A/= B;

 

So how can we determine whether a float/double value is (-1. # INF000?

The answer is yes.

 

We found that when a is-1. # INF000;

A performs any operation on its own.

 

So.

It is very simple, according to the example above.

When a/= B is executed, a is already =-1. # INF000

Let's judge:

If (a + 1 = a-1)

Return true; // indicates an invalid number.

 

In fact, the conclusion is that a + any number =;

 

 

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.