This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/_setmath.c

27 lines
565 B
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
#include <process.h>
#include <math.h>
/* Demonstrate error routine in which negative */
/* arguments to "sqrt" are treated as positive */
static int my_matherr( struct _exception *err )
{
if( strcmp( err->name, "sqrt" ) == 0 ) {
if( err->type == DOMAIN ) {
err->retval = sqrt( -(err->arg1) );
return( 1 );
} else
return( 0 );
} else
return( 0 );
}
void main( void )
{
_set_matherr( &my_matherr );
printf( "%e\n", sqrt( -5e0 ) );
exit( 0 );
}