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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,181acb4d59c58e23,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!t8g2000yqk.googlegroups.com!not-for-mail From: Rolf Newsgroups: comp.lang.ada Subject: evaluation of named numbers Date: Sun, 17 Oct 2010 08:01:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2304722c-027d-42f6-a45d-5a7646c35cf6@t8g2000yqk.googlegroups.com> NNTP-Posting-Host: 91.4.241.126 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1287327685 14883 127.0.0.1 (17 Oct 2010 15:01:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 17 Oct 2010 15:01:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t8g2000yqk.googlegroups.com; posting-host=91.4.241.126; posting-account=-RRRjAkAAAAGFvmHqTCN-L7gNQ7lRGfd User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 ( .NET CLR 3.5.30729),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:15559 Date: 2010-10-17T08:01:25-07:00 List-Id: I always thought that named numbers are fully evaluated with (almost) unlimited precision at compile time. I was quite astonished to see Ticks : constant := 20 / 1000 * 16_000_000 / 8; -- 40_000 ticks evaluated to 0 and not to the expected 40.000. It seems that the compiler uses integer numbers also for intermediate results and 20 / 1000 ends up to be 0 instead of 0.02. Any decent pocket calculator gets that right. The workaround is simple once I understood the problem: Ticks : constant := 20 * 16_000_000 / 8 / 1000; -- 40_000 ticks Are expressions for named numbers always evaluated left to right? I think I'll add an item to the review check list to always put multiplications on the left before any divisions. Rolf