Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.programming Subject: Re: Here is why C++ and C are bad... Date: Wed, 30 Dec 2015 16:32:52 +0000 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87bn977v7v.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="10197"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zuoKGMnxu0P9OsApcUUKSGrhSOlQIZRM=" Cancel-Lock: sha1:cH8Qp0iyIICpuHuIe4c54BsybdE= sha1:iY4r3h4LLCA0xeNeYw3k4fjudyc= X-BSB-Auth: 1.85965302ab7008296442.20151230163252GMT.87bn977v7v.fsf@bsb.me.uk Xref: csiph.com comp.programming:6081 David Brown writes: > On 30/12/15 14:28, Richard Heathfield wrote: >> int i = -6; >> unsigned int j = 42; >> if(i < j) >> { >> puts("-6 is less than 42"); >> } > Of course, this in itself is just a specialist case of the difference > between "normal" mathematics and numbers in C. Replace the first two > lines with "int16_t i = 1000000; int16_t j = 4000000;" and you'll find > that four million is apparently smaller than one million. You might find that, but you also might not! There is a conversion which is implementation-defined (and might even raise a signal). -- Ben.