Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!ut-sally!utah-cs!donn From: donn@utah-cs.UUCP (Donn Seeley) Newsgroups: comp.lang.c Subject: Re: unsigned int assigned to double yields negative # ... Why? Message-ID: <5355@utah-cs.UUCP> Date: 18 Mar 88 08:19:57 GMT References: <5020@nsc.nsc.com> Organization: University of Utah CS Dept Lines: 16 Keywords: conversions Summary: broken compilers This was a bug of long standing in the PCC. I fixed it for 4.3 BSD; vendors who use PCC-based compilers have been fixing it too, although this coverage has been spotty (I see that HP-UX finally fixes this in 6.0). For maximum portability you should probably restrict your use of this conversion, because the workarounds for the bug are ugly and there are still many buggy compilers. It's true that neither K&R nor ANSI give special mention to unsigned- to-floating conversions, but if the compilers weren't broken, I doubt the issue would have arisen. Donn Seeley University of Utah CS Dept donn@cs.utah.edu 40 46' 6"N 111 50' 34"W (801) 581-5668 utah-cs!donn PS -- Yes, I fixed the obvious printf() problems before trying the example; it'd sure be nice if people could test examples before posting them (especially in bug reports).