Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!ucbvax!agate!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclwjm!walter From: walter@hpclwjm.HP.COM (Walter Murray) Newsgroups: comp.lang.c Subject: Re: floating point constants Message-ID: <660047@hpclwjm.HP.COM> Date: 27 Jul 89 18:45:43 GMT References: <1925@arisia.Xerox.COM> Organization: Hewlett-Packard Calif. Language Lab Lines: 25 >>Is this a valid C program? >>main() >>{ >> printf("%f\n", 1.0/0.0); >> printf("%f\n", -1.0/0.0); >> printf("%f\n", 0.0/0.0); >>} >It's certainly not strictly conforming. Division by zero is handled in >an implementation-dependent way, including fatal compile-time error. Another interpretation is that it's a valid program, as long as you don't try to run it! An expression involving division by zero is not illegal unless that expression has to be evaluated, in which case behavior is undefined. Under ANSI C, I think it's clear that the following program is valid, and prints the value 1. main() { printf("%d\n", 2.0||1.0/0.0); } Walter Murray Not speaking for X3J11 ----------