From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c696,c887bec98cd793ef X-Google-Attributes: gid10c696,public X-Google-Thread: 111c93,c887bec98cd793ef X-Google-Attributes: gid111c93,public From: Remco Wouts Subject: Re: division by zero exceptions ? Date: 1998/10/27 Message-ID: #1/1 X-Deja-AN: 405482819 Sender: remco@localhost References: Content-Type: text/plain; charset=US-ASCII X-Trace: 27 Oct 1998 08:37:33 +0100, childish.bmc.uu.se Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.os.linux.alpha,comp.os.linux.development.apps conrad@hive.me.gu.edu.au (Conrad Sanderson) writes: > running this C++ program on an Alpha: > > void main() { > float a = 10.0; float b = 0.0; > float c = a/b; > cout << "c = " << c << endl; > } > > causes "Floating exception Exit 136", while on Intel PII is says: > "c = Inf", which is the "correct" answer. First of all, this is not the correct answer. Dividing by zero is nonsense. So actually the Alpha is right. What you mean, but what is completely different, is that when dividing by smaller and smaller numbers (in the limit /approaching/ zero) the resultant goes to infinity. If you don't want to check every divisor and handle exceptions you may want to search the documentation to see if you can trap these exceptions. But that was already suggested by somebody else. -- Remco Wouts remco@xray.bmc.uu.se | Dept. of Biochemistry, Uppsala University tel/fax:+46-18-4714642/511755 | PO Box 576, S-751 23 Uppsala, Sweden. WinErr: 00D Window closed - Do not look outside