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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,908b0acacbaccca8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-11 19:03:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!wn12feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!sccrnsc03.POSTED!not-for-mail From: "SteveD" Newsgroups: comp.lang.ada References: <7bd7d86e.0210110721.8097797@posting.google.com> Subject: Re: Integer data type X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: NNTP-Posting-Host: 12.211.13.75 X-Complaints-To: abuse@attbi.com X-Trace: sccrnsc03 1034388232 12.211.13.75 (Sat, 12 Oct 2002 02:03:52 GMT) NNTP-Posting-Date: Sat, 12 Oct 2002 02:03:52 GMT Organization: AT&T Broadband Date: Sat, 12 Oct 2002 02:03:52 GMT Xref: archiver1.google.com comp.lang.ada:29729 Date: 2002-10-12T02:03:52+00:00 List-Id: "Mark" wrote in message news:7bd7d86e.0210110721.8097797@posting.google.com... > Is it possible to extract the binary representation of an integer > variable and store that binary representation in another variable? > Yes. See http://www.adaic.org/standards/95lrm/html/RM-13-9.html for a description of Ada.Unchecked_Conversion. Here is a small example (tested) with Interfaces; use Interfaces; with Ada.Unchecked_Conversion; with Ada.Text_Io; procedure tobytes is package Int_16_Io is new Ada.Text_Io.Integer_Io( Integer_16 ); package Int_32_Io is new Ada.Text_Io.Integer_Io( Integer_32 ); type Two_16s is array( 1 .. 2 ) of Integer_16; function Conv is new Ada.Unchecked_Conversion( Integer_32, Two_16s ); in_32 : Integer_32; out_16s : Two_16s; begin Ada.Text_Io.Put( "Enter value: " ); Int_32_Io.Get( in_32 ); out_16s := Conv( in_32 ); Ada.Text_Io.Put( "The values are: " ); Int_16_Io.Put( out_16s( 1 ) ); Ada.Text_Io.Put( ", " ); Int_16_Io.Put( out_16s( 2 ) ); Ada.Text_Io.New_Line; end tobytes; > Thanks, > > Mark You're welcome. SteveD