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,252713cea9bdfef9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-12 05:54:00 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!195.27.83.146.MISMATCH!news-FFM2.ecrc.net!news.siemens.de!news.mch.sbs.de!not-for-mail From: Alfred Hilscher Newsgroups: comp.lang.ada Subject: Re: convert integer base10 into base16 Date: Tue, 12 Feb 2002 14:53:56 +0100 Organization: Siemens AG Message-ID: <3C691E74.817FF860@icn.siemens.de> References: <8fe5cfbb.0202120405.19690c26@posting.google.com> NNTP-Posting-Host: 139.21.122.158 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:19932 Date: 2002-02-12T14:53:56+01:00 List-Id: c-kif-kif wrote: > > I'm shure this question has been answered a million times, > but i still can't get it right. > > It's easy to convert base10 into base16 : > a : integer := 16#A#; > a := Integer'Value (Integer'Image(a)); -- result 10 > > But how can i convert from base10 to base16 or other ? > > I don't want to write it on screen, so i think it's not with put/get how it works. > > Thanks for any help > c-kif-kif You want convert a number to the hex-representation in a string? package Integer_IO do this for you. procedure Get(From : in String; Item : out Num; Last : out Positive); 16 Reads an integer value from the beginning of the given string, following the same rules as the Get procedure that reads an integer value from a file, but treating the end of the string as a file terminator. Returns, in the parameter Item, the value of type Num that corresponds to the sequence input. Returns in Last the index value such that From(Last) is the last character read. 17 The exception Data_Error is propagated if the sequence input does not have the required syntax or if the value obtained is not of the subtype Num. 18 procedure Put(To : out String; Item : in Num; Base : in Number_Base := Default_Base); 19 Outputs the value of the parameter Item to the given string, following the same rule as for output to a file, using the length of the given string as the value for Width.