Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!security!genrad!grkermit!masscomp!clyde!floyd!vax135!ukc!root44!addw From: addw@root44.UUCP Newsgroups: net.lang.c Subject: Re: Re: Problem in type conversion Message-ID: <4232@root44.UUCP> Date: Thu, 19-Jan-84 01:19:51 EST Article-I.D.: root44.4232 Posted: Thu Jan 19 01:19:51 1984 Date-Received: Sat, 14-Jan-84 02:58:08 EST Lines: 33 <<<<>>>> Roger L. Ferrel said: >> What we see here with the: >> >> inttype *= 0.5; >> vs >> inttype = inttype * 0.5; >> >> is a weekness of most C compilers. It seems none of them handles float >> operations very well when there are mixed types. Of course the above is >> a poor example since normally more efficent code would be generated by >> using: >> >> intype >>= 1; /* how is this for getting off the subject? */ Unfortunately this is only guaranteed to work if: 1) inttype is unsigned -plainly not the intention. 2) inttype is positive, if inttype is negative it is undefined what is put into the top bit; ie your negative number may become positive. (A '1' will be inserted on a PDP11, but I assume that it is intended to write portable programs. I don't know what other machines will do.) There is little point in being efficient but wrong. The only real alternative is: inttype /= 1; Alain Williams Root Computers Ltd, London. {ENGLAND}!ukc!root44!addw PS, In England we spell the word that means 'lack of strength' as weakness, & efficent as efficient.