Archived

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

Floating

Is there a fast function isFloatValid(float f) ?

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