Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: doubles used as booleans Message-ID: <1989Mar31.172505.25455@utzoo.uucp> Organization: U of Toronto Zoology References: <8269@xanth.cs.odu.edu> Date: Fri, 31 Mar 89 17:25:05 GMT In article <8269@xanth.cs.odu.edu> kremer@cs.odu.edu (Lloyd Kremer) writes: > Can a double be used directly as a boolean? Any "scalar" type -- an arithmetic or pointer type -- can. > The optimizing in the compilers I was using was minimal, and I > found that substitutions such as 'if(i)' instead of 'if(i != 0)', > and 'if(!n)' in place of 'if(n == 0)' produced smaller code for > integral types... Talk about lazy compilers... > [compilers that balk at doing implicit comparison against 0 for double] > ... Would these compilers be officially broken by today's standards? Yes. They've been officially broken by the prevailing de-facto standards all along, as well. -- Welcome to Mars! Your | Henry Spencer at U of Toronto Zoology passport and visa, comrade? | uunet!attcan!utzoo!henry henry@zoo.toronto.edu