comp.lang.ada
 help / color / mirror / Atom feed
From: "Bob Gratton" <bobby@sympatico.ca>
Subject: Re: Binary value
Date: Fri, 30 Mar 2001 18:20:24 GMT
Date: 2001-03-30T18:20:24+00:00	[thread overview]
Message-ID: <I74x6.569791$JT5.15739046@news20.bellglobal.com> (raw)
In-Reply-To: 9a2gge$6m$1@nh.pace.co.uk

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4432 bytes --]

GEE!!! Thanx a lot! You cannot guess how much this will help...
I should send you a check! My VISA number! A box of chocolate chip cookies!
I'm just beginning in Ada, but you just gave me the tools I needed...

Thanx again!

"Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> a �crit dans
le message news: 9a2gge$6m$1@nh.pace.co.uk...
> As I said, you have features in Text_IO to display data in forms other
than
> base 10.
>
> Step 1: Bookmark this site: http://www.adapower.org/
> Step 2: Click on the "Reference" button and select "On-line version of the
> Ada 95 Reference Manual at AdaPower.com"
> Step 3: Find: Appendix A.10.8, wherein you will find documentation on the
> "Put" procedure. (Check out all the other cool stuff while you're there,
> like the various Ada.Strings... packages, etc. Lots of useful tools for
you
> there.) A copy here for your convenience:
>
> ====================================================
> procedure Put(File  : in File_Type;
>               Item  : in Num;
>               Width : in Field := Default_Width;
>               Base  : in Number_Base := Default_Base);
>
> procedure Put(Item  : in Num;
>               Width : in Field := Default_Width;
>               Base  : in Number_Base := Default_Base);
>
> Outputs the value of the parameter Item as an integer literal, with no low
> lines, no exponent, and no leading zeros (but a single zero for the value
> zero), and a preceding minus sign for a negative value.
> If the resulting sequence of characters to be output has fewer than Width
> characters, then leading spaces are first output to make up the
difference.
> Uses the syntax for decimal literal if the parameter Base has the value
ten
> (either explicitly or through Default_Base); otherwise, uses the syntax
for
> based literal, with any letters in upper case.
> ====================================================
>
> If you intend to do very much programming in Ada at all, you'll want to
get
> nice and comfortable with the ARM. Check out AdaPower as a really first
rate
> resource - especially the on-line version of the ARM. (BTW: Many compilers
> ship with some version of the ARM available to you.)
>
> Hope this helps.
>
> MDC
> --
> Marin David Condic
> Senior Software Engineer
> Pace Micro Technology Americas    www.pacemicro.com
> Enabling the digital revolution
> e-Mail:    marin.condic@pacemicro.com
> Web:      http://www.mcondic.com/
>
>
> "Bob Gratton" <bobby@sympatico.ca> wrote in message
> news:ub3x6.569521$JT5.15735623@news20.bellglobal.com...
> > I see... that answers half of my question. This presumes I wanna convert
> > from binary to Integer. But is it possible to "convert" a Integer value
to
> > binary. For example, if one of my program's users enters a value, how
can
> I
> > show him the conversion in binary?
> >
> > "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com> a �crit
dans
> > le message news: 9a2dnu$sff$1@nh.pace.co.uk...
> > > It could not possibly get any easier. Ada allows you to express
numeric
> > > literals in bases other than 10. The syntax is B#nnnn# where B is a
base
> > and
> > > the nnnn is the number in appropriate base representation. (octal,
hex,
> > > binary,... base 7 or 5 if you want to be unique!) So a binary number
> could
> > > be expressed as:
> > >
> > > 2#1111_1111_1111_1111#
> > >
> > > or just for fun:
> > >
> > > 16#FFFF#
> > > 8#177777#
> > > 10#65535#
> > >
> > > IIRC, you can only use bases between 2..16 - but that covers most of
the
> > > ground anybody would want.
> > >
> > > Note also that burried somewhere in Text_IO are routines that will
allow
> > you
> > > to print results using a base other than 10 - just in case you want to
> do
> > a
> > > little I/O with your bits...
> > >
> > > MDC
> > > --
> > > Marin David Condic
> > > Senior Software Engineer
> > > Pace Micro Technology Americas    www.pacemicro.com
> > > Enabling the digital revolution
> > > e-Mail:    marin.condic@pacemicro.com
> > > Web:      http://www.mcondic.com/
> > >
> > >
> > > "Bob Gratton" <bobby@sympatico.ca> wrote in message
> > > news:9e2x6.568987$JT5.15730002@news20.bellglobal.com...
> > > > Ok... now I know how to use bitwise operators... I'd like to know
also
> > how
> > > > to convert an integer value to its equivalent in binary.
> > > >
> > > > e.g.: 123 => 1111011
> > > >
> > > > Thanx again!
> > > >
> > > > Bob
> > > >
> > > >
> > >
> > >
> >
> >
>
>





  reply	other threads:[~2001-03-30 18:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-30 16:10 Binary value Bob Gratton
2001-03-30 16:54 ` Marin David Condic
2001-03-30 17:16   ` Bob Gratton
2001-03-30 17:41     ` Marin David Condic
2001-03-30 18:20       ` Bob Gratton [this message]
2001-03-30 19:58         ` Marin David Condic
2001-03-30 18:21     ` chris.danx
2001-03-30 20:03       ` Marin David Condic
2001-03-30 20:32       ` Smark
2001-03-30 20:45         ` Smark
2001-03-30 21:19           ` chris.danx
2001-03-31  5:23       ` Phaedrus
     [not found]         ` <3AC5C72F.8108A613@earthlink.net>
2001-04-01 19:52           ` Phaedrus
2001-04-01 22:04             ` Robert A Duff
2001-04-01 22:35               ` David C. Hoos, Sr.
2001-04-02 12:49               ` Marc A. Criley
2001-04-02 13:33             ` chris.danx
2001-04-02 14:33             ` Marin David Condic
2001-04-02 16:43       ` Jeffrey Carter
2001-04-02 17:36         ` chris.danx
2001-04-02 18:03           ` Robert A Duff
2001-04-02 17:54         ` Robert A Duff
2001-03-30 17:03 ` Larry Hazel
replies disabled

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