comp.lang.ada
 help / color / mirror / Atom feed
From: Petter Fryklund <petter.fryklund@atero.se>
Subject: Re: Fortran 95: How do you write code to do this?
Date: Thu, 1 Nov 2018 00:13:46 -0700 (PDT)
Date: 2018-11-01T00:13:46-07:00	[thread overview]
Message-ID: <d3e1e9f6-0759-487a-999e-6a9e1bbefcec@googlegroups.com> (raw)
In-Reply-To: <a1868ec7-2a4d-4802-a28e-1ba878e54bc0@googlegroups.com>

Assuming rightmost means LSB:

generic 
  type T is mod <>;
function Boolean_Of(Nat : T) return Boolean;

function Boolean_Of(Nat : T) return Boolean is
begin
  return (Nat and 1) = 1;
end Boolean_Of;

type Ten_Bits is 2 ** 10;

function Boolean_Of_Ten_Bits is new Boolean_Of(Ten_Bits);

Input : Ten_Bits := 75;
Bool  : Boolean  := Boolean_Of_Ten_Bits(Input); -- will be True

regards,
Petter


  reply	other threads:[~2018-11-01  7:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  5:34 Fortran 95: How do you write code to do this? Michael_Smith@gmail.com
2018-11-01  7:13 ` Petter Fryklund [this message]
2018-11-01  7:18   ` Petter Fryklund
2018-11-01 16:35     ` Michael_Smith@gmail.com
2018-11-01 17:59       ` Jacob Sparre Andersen
2018-11-02  6:19         ` Petter Fryklund
2018-11-02  6:33           ` Petter Fryklund
2018-11-02  8:41             ` Dmitry A. Kazakov
2018-11-01  7:54   ` Simon Wright
2018-11-02  9:05 ` Anatoly Chernyshev
2018-11-02  9:14   ` gautier_niouzes
2018-11-02 14:37   ` Dennis Lee Bieber
replies disabled

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