Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!cs.utexas.edu!samsung!munnari.oz.au!metro!news From: rossc@extro.ucc.su.oz.au (Ross Cartlidge) Newsgroups: comp.sys.mips Subject: SIGFPE and atan2 Message-ID: <1990Sep19.071533.18643@metro.ucc.su.OZ.AU> Date: 19 Sep 90 07:15:33 GMT Reply-To: rossc@extro.ucc.su.oz.au (Ross Cartlidge) Organization: University Computing Service, Uni. of Sydney, Australia. Lines: 68 When I called do a:- atan2(1.0, 0.0) on a M/2000 running RISC/OS 4.5 I get a divide by zero exception. On other machines I have tried I do not. As atan2(1.0, 0.0) is defined (PI/2) does anyone know why I get this exception. If I don't enable div by zero exceptions it gives the correct answer. The programs below demonstrates the problem on a MIPS as compared to a Sun 4/60. #include #include #include main() { double f; double z; int c(); union fpc_csr csr; signal(SIGFPE, c); csr.fc_word = get_fpc_csr(); csr.fc_struct.en_divide0 = 1; csr.fc_struct.en_overflow = 1; csr.fc_struct.en_invalid = 1; set_fpc_csr(csr.fc_word); f = atan2(1.0, 0.0); printf("f = %f\n", f); } c() { printf("FPE\n"); } This program shows the behaviour on a Sun 4/60:- #include #include main() { double f; double z; int c(); char *out; printf("%d\n", ieee_handler("set","all",c)); printf("out = %s\n", out); f = atan2(1.0, 0.0); printf("f = %f\n", f); } c() { printf("FPE\n"); } -- ________________________________________________________________________ Ross Rodney Cartlidge | rossc@extro.ucc.su.oz.au University Computing Service, H08 | Phone: +61 2 6923497 University of Sydney, NSW 2006, Australia | FAX: +61 2 6606557