comp.lang.ada
 help / color / mirror / Atom feed
* Re: Help!! Writing binary bit by bit
       [not found] <5j0vh0$2d1$3@cathedral.cerc.wvu.edu>
@ 1997-04-16  0:00 ` Gautier
  1997-04-16  0:00 ` Larry Kilgallen
  1997-04-18  0:00 ` Robert Dewar
  2 siblings, 0 replies; 5+ messages in thread
From: Gautier @ 1997-04-16  0:00 UTC (permalink / raw)



> Is there any sort of IO that i'm not familiar with that gives the programmer 
> control over how many bits are written, and exactly what bits those are 
> (0's or 1's)? That is the only way I see to translate without having an IO 
> package translate for me.

For input, the format 2#0010010101110# should work (2=base; a std format in Ada)
For output, type <<Put(n,base=>2);>> or something like that.
Since you can use <<Put>> to write into a string, you can control all that.

> If I wanted to write 001101, and that's all, not the binary equvalent for
> each digit. If I wanted to write one binary digit at a time, is it possible,
> or is there a more appropriate place to find out?
> 
> I appreciate any and all input!!
> 
> -
> e-mail   :  mcgreal@cs.wvu.edu




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

* Re: Help!! Writing binary bit by bit
       [not found] <5j0vh0$2d1$3@cathedral.cerc.wvu.edu>
  1997-04-16  0:00 ` Help!! Writing binary bit by bit Gautier
@ 1997-04-16  0:00 ` Larry Kilgallen
  1997-04-18  0:00 ` Robert Dewar
  2 siblings, 0 replies; 5+ messages in thread
From: Larry Kilgallen @ 1997-04-16  0:00 UTC (permalink / raw)



In article <5j0vh0$2d1$3@cathedral.cerc.wvu.edu>, mcgreal@cs.wvu.edu (Martin McGreal) writes:
> I'm trying to write a program that converts normal binary or ascii files into
> Huffman code. I was going to use indexed_io's procedure read_by_key to
> allocate the amount of bits used, but it turns out you can only allocate 
> BYTES with that procedure (i'm fairly certain, call me on that if you can).
> 
> Is there any sort of IO that i'm not familiar with that gives the programmer 
> control over how many bits are written, and exactly what bits those are 
> (0's or 1's)? That is the only way I see to translate without having an IO 
> package translate for me.
> 
> If I wanted to write 001101, and that's all, not the binary equvalent for
> each digit. If I wanted to write one binary digit at a time, is it possible,
> or is there a more appropriate place to find out?

In DEC Ada on VMS (my presumption -- your newswriter seems to be having
hiccups today) generic package INDEXED_IO is layered on top of the Record
Management System (RMS) provided by VMS.  RMS has a minimum granularity in
record size of 1 byte.

You will need some higher level mechanism to indicate how many of those
bits are actually meaningful.  I would suggest the ASN.1 encoding of BIT
STRING.  Then again, I am becoming an ASN.1 bigot in addition to a VMS
bigot, an Ada bigot (and for that matter, an RMS bigot).

Of course if you wanted some particular _ordering_ out of the resultant
keys (as distinguished from direct lookup) BIT STRING would be a bad
choice.

Larry Kilgallen




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

* Re: Help!! Writing binary bit by bit
       [not found] <5j0vh0$2d1$3@cathedral.cerc.wvu.edu>
  1997-04-16  0:00 ` Help!! Writing binary bit by bit Gautier
  1997-04-16  0:00 ` Larry Kilgallen
@ 1997-04-18  0:00 ` Robert Dewar
  1997-04-21  0:00   ` Michael F Brenner
  2 siblings, 1 reply; 5+ messages in thread
From: Robert Dewar @ 1997-04-18  0:00 UTC (permalink / raw)



Martin said

<<If I wanted to write 001101, and that's all, not the binary equvalent for
each digit. If I wanted to write one binary digit at a time, is it possible,
or is there a more appropriate place to find out?>>

This sounds like a homework assignment (Huffman coding is a classical
excercise in beginning programming), and you are going about it in entirely
the wrong way, since obviously the result needs to be built in memory, not
written out a bit at a time. I suggest you contact your instructor or
teaching assistant to understand the assignment better before trying to
start coding.





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

* Re: Help!! Writing binary bit by bit
  1997-04-18  0:00 ` Robert Dewar
@ 1997-04-21  0:00   ` Michael F Brenner
  1997-04-23  0:00     ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: Michael F Brenner @ 1997-04-21  0:00 UTC (permalink / raw)



RD said: > Huffman coding ... the result needs to be built in memory, not
         > written out a bit at a time.

What? Once the tree is built, the logical model for outputting the code is
a bit at a time output. The same for pcx, jpeg, tiff, dvi, pk, zip, and
many other compression, graphics, encoding, or binary file formats.

There is nothing wrong with having a straight-forward way to take this
logical bit-at-a-time output concept and showing how to do it efficiently
in Ada-95. Unfortunately, it appears, that you must write your own 
buffering scheme in a non-portable manner, to do this. If anyone has
ideas how to do this portably, I am interested.





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

* Re: Help!! Writing binary bit by bit
  1997-04-21  0:00   ` Michael F Brenner
@ 1997-04-23  0:00     ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1997-04-23  0:00 UTC (permalink / raw)



Michael says

<<There is nothing wrong with having a straight-forward way to take this
logical bit-at-a-time output concept and showing how to do it efficiently
in Ada-95. Unfortunately, it appears, that you must write your own
buffering scheme in a non-portable manner, to do this. If anyone has
ideas how to do this portably, I am interested.>>

I can't understand why you think that this particular task should involve
non-portable constructs -- you must have some approach in mind that is
not apparent. Can you elaborate? It seems perfectly straightforward to
use stream_io, assembling bits into storage elements in a portable manner.





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

end of thread, other threads:[~1997-04-23  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5j0vh0$2d1$3@cathedral.cerc.wvu.edu>
1997-04-16  0:00 ` Help!! Writing binary bit by bit Gautier
1997-04-16  0:00 ` Larry Kilgallen
1997-04-18  0:00 ` Robert Dewar
1997-04-21  0:00   ` Michael F Brenner
1997-04-23  0:00     ` Robert Dewar

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