comp.lang.ada
 help / color / mirror / Atom feed
From: "Vinzent Hoefler" <nntp-2010-10@t-domaingrabbing.de>
Subject: Re: evaluation of named numbers
Date: Sun, 17 Oct 2010 17:28:58 +0200
Date: 2010-10-17T17:28:58+02:00	[thread overview]
Message-ID: <op.vkp7ykef0k3wt7@jellix.jlfencey.com> (raw)
In-Reply-To: 2304722c-027d-42f6-a45d-5a7646c35cf6@t8g2000yqk.googlegroups.com

On Sun, 17 Oct 2010 17:01:25 +0200, Rolf <rolf.ebert_nospam_@gmx.net> wrote:

> 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.

Well, after all it's an integer expression. I wouldn't expect a real
result when doing that - not even as an intermediate result.

> Any decent pocket calculator gets that right.

Because it uses real numbers.

> Are expressions for named numbers always evaluated left to right?

According to ARM 4.5(8), yes.


Vinzent.

-- 
There is no signature.



  reply	other threads:[~2010-10-17 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-17 15:01 evaluation of named numbers Rolf
2010-10-17 15:28 ` Vinzent Hoefler [this message]
2010-10-17 16:05 ` Robert A Duff
2010-10-17 18:32   ` Georg Bauhaus
2010-10-17 18:57 ` Nasser M. Abbasi
2010-10-17 22:30 ` anon
2010-10-17 22:32 ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox