From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a9b0810d3106d9b8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!a11g2000pro.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Elias_Salom=E3o_Helou_Neto?= Newsgroups: comp.lang.ada Subject: Re: Fun with C Date: Sun, 17 Apr 2011 12:19:01 -0700 (PDT) Organization: http://groups.google.com Message-ID: <3ccf18a2-ba10-42bc-aeab-9368749961fb@a11g2000pro.googlegroups.com> References: <27cf3992-4132-4483-9110-adc7a089cd4a@e8g2000vbz.googlegroups.com> NNTP-Posting-Host: 186.223.216.44 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1303067942 4702 127.0.0.1 (17 Apr 2011 19:19:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 17 Apr 2011 19:19:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a11g2000pro.googlegroups.com; posting-host=186.223.216.44; posting-account=8auP9QoAAACkSx2qxJhP83KA6-tg78E8 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.8 SUSE/7.0.528.0 (KHTML, like Gecko) Chrome/7.0.528.0 Safari/534.8,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19809 Date: 2011-04-17T12:19:01-07:00 List-Id: On Apr 16, 2:02=A0pm, "George P." wrote: > Spend few days chasing bug in embedded C project which can drilled > down to this. Consider the following program, and all reasonable men > will expect the result to be negative. =A0Not in C, and it is not a > compiler bug :-( All reasonable men will try to learn the language before programming. The mentioned behavior is the one C is supposed to have, whether you like it or not. It one of the first thing I teach in my C classes: type promotions in expression. They may be dumb, or may not, I will not argue on that. But being reasonable is knowing the tool before trying to use it. Is this also a bug? int i =3D 1; int j =3D 2; double result =3D i / j; printf("%lf\n", result); results in 0 being output. Oh my god, C can't perform arithmetic division! More fun with C?