comp.lang.ada
 help / color / mirror / Atom feed
* pre-defined function convert hex to decimal?
@ 2002-11-20 17:12 Sarah Thomas
  0 siblings, 0 replies; 4+ messages in thread
From: Sarah Thomas @ 2002-11-20 17:12 UTC (permalink / raw)


is there a pre-defined function in ada that converts hex to decimal,
or do I have to write from scratch? thanks



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

* Re: pre-defined function convert hex to decimal?
       [not found] <mailman.1037815682.9555.comp.lang.ada@ada.eu.org>
@ 2002-11-20 18:44 ` Robert A Duff
  2002-11-21 13:39   ` Marin David Condic
  0 siblings, 1 reply; 4+ messages in thread
From: Robert A Duff @ 2002-11-20 18:44 UTC (permalink / raw)


"Beard, Frank Randolph CIV" <frank.beard@navy.mil> writes:

> Look at the Integer_IO routines, Put and Get, inside Ada.Text_IO.
> Pay particular attention to the "Base" parameter.  Try calling Put
> (to a File) with the base parameter set to your desired base, and
> then read that value back in with Get (from a File).  You can 
> do something similar with the Put/Get to/from string routines.

To/from a File?!  Surely you mean String.

Also, the 'Image and 'Value can also be used for hex-to-decimal
(but not the other way around).

- Bob



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

* Re: pre-defined function convert hex to decimal?
@ 2002-11-20 19:49 Gautier direct_replies_not_read
  0 siblings, 0 replies; 4+ messages in thread
From: Gautier direct_replies_not_read @ 2002-11-20 19:49 UTC (permalink / raw)


>is there a pre-defined function in ada that converts hex to decimal,
>or do I have to write from scratch? thanks

You can use the 'Image and 'Value attributes. E.g.:

with Ada.Text_IO;
procedure Test_hex_to_dec is
begin
  Ada.Text_IO.Put( Integer'Image( Integer'Value("16#1A2B3C#") ) );
end;
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

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


_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus




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

* Re: pre-defined function convert hex to decimal?
  2002-11-20 18:44 ` Robert A Duff
@ 2002-11-21 13:39   ` Marin David Condic
  0 siblings, 0 replies; 4+ messages in thread
From: Marin David Condic @ 2002-11-21 13:39 UTC (permalink / raw)


Robert A Duff <bobduff@shell01.TheWorld.com> wrote in message
news:wccel9gdqsp.fsf@shell01.TheWorld.com...
> "Beard, Frank Randolph CIV" <frank.beard@navy.mil> writes:
>
> > Look at the Integer_IO routines, Put and Get, inside Ada.Text_IO.
> > Pay particular attention to the "Base" parameter.  Try calling Put
> > (to a File) with the base parameter set to your desired base, and
> > then read that value back in with Get (from a File).  You can
> > do something similar with the Put/Get to/from string routines.
>
> To/from a File?!  Surely you mean String.
>
> Also, the 'Image and 'Value can also be used for hex-to-decimal
> (but not the other way around).
>

It might be useful for a beginner to use a file at first to see what the
results look like. From there, obviously, its better to use a string for any
real work.

MDC
--
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jast.mil/

Send Replies To: m c o n d i c @ a c m . o r g

    "I'd trade it all for just a little more"
        --  Charles Montgomery Burns, [4F10]
======================================================================





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

end of thread, other threads:[~2002-11-21 13:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-20 19:49 pre-defined function convert hex to decimal? Gautier direct_replies_not_read
     [not found] <mailman.1037815682.9555.comp.lang.ada@ada.eu.org>
2002-11-20 18:44 ` Robert A Duff
2002-11-21 13:39   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2002-11-20 17:12 Sarah Thomas

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