comp.lang.ada
 help / color / mirror / Atom feed
From: "Xenos" <dont.spam.me@spamhate.com>
Subject: Re: Hex ouput
Date: Thu, 23 Oct 2003 15:51:04 -0400
Date: 2003-10-23T15:51:04-04:00	[thread overview]
Message-ID: <bn9bfu$pho5@cui1.lmms.lmco.com> (raw)
In-Reply-To: 3F97F61A.13088097@raytheon.com


"Jerry Petrey @raytheon.com>" <"jdpetrey<NOSPAM> wrote in message
news:3F97F61A.13088097@raytheon.com...
> You can find the Ada LRM at Amazon, among other places:
>
http://www.amazon.com/exec/obidos/tg/detail/-/3540430385/qid=1066923022/sr=1
-1/ref=sr_1_1/102-5165323-3419326?v=glance&s=books
>
> Also if you want to output hex numbers without the 16#xxxx# format, here
is a
> short routine to do that:
>
>
>     procedure Hex_Print (Num                  : in Integer;
>                                       Num_Of_Digits : in Positive) is
>
>         Temp_Str    : String (1 .. Num_Of_Digits + 5) := (others => '0');
>         New_Str     : String (1 .. Num_Of_Digits)     := (others => '0');
>         First_Digit : Positive;
>
>     begin
>
>         Put (To => Temp_Str, Item => Num, Base => 16);
>
>         for I in 1 .. Num_Of_Digits + 4 loop
>             if Temp_Str (I) = '#' then
>                 First_Digit := I + 1;
>                 exit;
>             end if;
>         end loop;
>
>         New_Str (First_Digit - 4 .. Num_Of_Digits) :=
>            Temp_Str (First_Digit .. Num_Of_Digits + 4);
>         Put (New_Str);
>
>     end Hex_Print;
>
> It could be improved some but should help you get the idea.
>
> Jerry
> --
> --------------------------------------------------------------------------
-------
>
> -- Jerry Petrey
> -- Senior Principal Systems Engineer - Navigation (GPS/INS), Guidance, &
> Control
> -- Raytheon Missile Systems          - Member Team Ada & Team Forth
> -- NOTE: please remove <NOSPAM> in email address to reply
> --------------------------------------------------------------------------
-------
>
>
>

Thanks for the link!  Incidentally, You can strip the 16# and the trailing #
just by taking a slice.  Assuming no leading or trailing spaced (Trim works
nicely), I just used: S(4 .. S'Length - 1)

Thanks,

DrX.





  reply	other threads:[~2003-10-23 19:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-22 16:56 Hex ouput Xenos
2003-10-22 17:19 ` Ed Falis
2003-10-23 13:34   ` Xenos
2003-10-23 14:14     ` Hard copy of Ada RM (was: Hex ouput) Ed Falis
2003-10-23 14:57       ` Xenos
2003-10-24  6:24       ` Dirk Craeynest
2003-10-23 15:39     ` Hex ouput Jerry Petrey
2003-10-23 19:51       ` Xenos [this message]
2003-10-23 21:18         ` Stephen Leake
2003-10-24  7:36         ` Dmitry A. Kazakov
2003-10-24  1:09       ` Jeffrey Carter
2003-10-24 15:08         ` Robert Spooner
2003-10-25  0:39           ` Jeffrey Carter
2003-10-26  1:16             ` Jeffrey Carter
2003-10-23 23:49     ` Randy Brukardt
replies disabled

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