comp.lang.ada
 help / color / mirror / Atom feed
From: cet1@cl.cam.ac.uk (C.E. Thompson)
Subject: Re: how to do this in Ada?
Date: 19 Mar 90 17:11:39 GMT	[thread overview]
Message-ID: <1811@gannet.cl.cam.ac.uk> (raw)
In-Reply-To: 256@avocado.uucp

In article <256@avocado.uucp> garym@sugar.hackercorp.com writes:
> ...
>The C compiler will probably generate a table jump.  But before it can index
>into the table it must make sure that the index is within the range 0..2, that
>takes 2 compares.  ...

A common fallacy. With any machine instruction set that you care to name,
you will find that you can test a value for being in the range a..b with 
an add/subtract and one compare (and subsequent conditional branch): usually
a subtract of 'a' and an unsigned comparison with 'b-a'. If a is zero, as
here, the subtract disappears as well.

Of course, this applies to the Ada range test as well.

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk

  reply	other threads:[~1990-03-19 17:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-03-18  3:23 how to do this in Ada? Gary Morris
1990-03-19 17:11 ` C.E. Thompson [this message]
  -- strict thread matches above, loose matches on Subject: below --
1990-03-13 18:56 westley
1990-03-15 16:40 ` RCAPENER
replies disabled

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