From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Fri, 18 Apr 2014 16:10:58 -0400 To: 9fans@9fans.net Message-ID: <72d84d382ece571ee9be74a694b20d7d@ladd.quanstro.net> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Floating point and dividing by 0 Topicbox-Message-UUID: d9c7bf18-ead8-11e9-9d60-3106f5b1d025 i imagine what happened is your kernel doesn't really do the right thing on catching the exception. i think the caught exception should restart the program *exactly* where it left off, dividing by zero, which will lead to an infinite loop. if your kernel skipped the instruction, then the value of (in my case r) would be whatever the previous value was. if this is the statement that initializes r, this could be random trash on the stack. which would lead to a mystery exception later on for some value of trash on stack. - erik ---- this provides the correct result. #include #include void main(void) { double zero, r; setfcr(getfcr() & ~FPZDIV); zero = 0.; r = 1.; r = r/zero; print("%g\n", r); exits(""); }