comp.lang.ada
 help / color / mirror / Atom feed
* Perform "or" on a scalar type?
@ 2002-02-26 10:53 Verner
  2002-02-26 11:40 ` Larry Kilgallen
  2002-02-26 16:05 ` Matthew Heaney
  0 siblings, 2 replies; 4+ messages in thread
From: Verner @ 2002-02-26 10:53 UTC (permalink / raw)


Hi,

What is the easyiest way to persorm an "or" operation on a Unsigned_16 and a
scalar type?

Thanks.

/V





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perform "or" on a scalar type?
  2002-02-26 10:53 Perform "or" on a scalar type? Verner
@ 2002-02-26 11:40 ` Larry Kilgallen
  2002-02-26 16:05 ` Matthew Heaney
  1 sibling, 0 replies; 4+ messages in thread
From: Larry Kilgallen @ 2002-02-26 11:40 UTC (permalink / raw)


In article <a5fnvq$6c3$1@newstoo.ericsson.se>, "Verner" <sebastian.madunic@avionics.saab.se> writes:

> What is the easyiest way to persorm an "or" operation on a Unsigned_16 and a
> scalar type?

Perform conversions so they have the same type.

A hallmark of Ada is the notion that conversions are explicit where
in other languages they might be implicit.  The attitude with Ada is
that it is not sufficient for you to understand what you want -- you
must specify it to the compiler.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perform "or" on a scalar type?
@ 2002-02-26 12:22 Gautier Write-only-address
  0 siblings, 0 replies; 4+ messages in thread
From: Gautier Write-only-address @ 2002-02-26 12:22 UTC (permalink / raw)


Verner:

>What is the easyiest way to persorm an "or" operation on a
>Unsigned_16 and a scalar type?

If you want to perform your "or" between u: Unsigned_16 and
s: A_scalar_Type, convert to Unsigned_16 where this
operator is meaningful and uniquely defined.

u or Unsigned_16(s)

HTH
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, address on the Web site!


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Perform "or" on a scalar type?
  2002-02-26 10:53 Perform "or" on a scalar type? Verner
  2002-02-26 11:40 ` Larry Kilgallen
@ 2002-02-26 16:05 ` Matthew Heaney
  1 sibling, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 2002-02-26 16:05 UTC (permalink / raw)



"Verner" <sebastian.madunic@avionics.saab.se> wrote in message
news:a5fnvq$6c3$1@newstoo.ericsson.se...
> What is the easyiest way to persorm an "or" operation on a Unsigned_16 and
a
> scalar type?

Unsigned_16 already has a build-in "or" operation:

declare
   I, J : Unsigned_16 := ...;
begin
   ... I or J ...
end;

If you want to mix U16 with other types (a signed integer, say), then you'll
have to convert the type to unsigned.  You have to decide whether a straight
type conversion is appropriate, or whether Unchecked_Conversion is
necessary, e.g.

function To_Unsigned is new Unchecked_Conversion (Integer_16, Unsigned_16);

declare
   I : Unsigned_16 := ...;
   J : Integer_16 := ...;
   K : Unsigned_16 := I or To_Unsigned (J);
begin







^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-26 16:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-26 10:53 Perform "or" on a scalar type? Verner
2002-02-26 11:40 ` Larry Kilgallen
2002-02-26 16:05 ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
2002-02-26 12:22 Gautier Write-only-address

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