Archived

This topic is now archived and is closed to further replies.

Is there a fast function isFloatValid(float f) ?

This topic is 5311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Do you know of a fast function which checks whether a float is valid or not? 1.#INF0 would be an invalid value I found the following code:
	unsigned short int axreg;
	__asm	
	{		
		fld value		// load float value		

		fxam			// check it

		fstsw ax		// get status word		

		mov axreg,ax	// let us access in c++	

	}	
	if ((axreg&0x500)!=0x500)	// check for INF

		return(false);
	return(true);
Is this enough? Or can a flot have another invalid value? I always thought division by zero and overflow have distinct values. Thanks

Share this post


Link to post
Share on other sites
I think an invalid float in the FPU was called a Nan.. it''s been awhile. check the processor manuals at www.x86.org

Share this post


Link to post
Share on other sites