What binary manipulation tools are there? - Unix

This is a discussion on What binary manipulation tools are there? - Unix ; Having no mathematical skills or the required white brain cell* activity to develop them I have utterly failed to produce a tool that can convert small strings into unsigned chars of their binary equivalents. For example a file containing (in ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: What binary manipulation tools are there?

  1. What binary manipulation tools are there?

    Having no mathematical skills or the required white brain cell*
    activity to develop them
    I have utterly failed to produce a tool that can convert small strings
    into unsigned chars
    of their binary equivalents.
    For example a file containing (in ASCII):

    1 1010
    111 10

    would become a file containing (as numeric values): 1 10 7 2

    I've tried oktata and it required anding, oring and xoring everything
    instead of straight
    forward editing. It also suggested in the manual that that was the
    traditional technique.


    So what tools (if any are there) for editing a binary by just...
    editing it rather
    than doing a heap of maths on all but the correct byte?

    *These connect the regions of the brain and in my case run very
    slowly.
    Every thing except lexical analysis (remembering words and word
    patterns)
    and logic (grammar) are stuffed without working with everything else
    non-stop.

  2. Re: What binary manipulation tools are there?

    RyanMcCoskrie wrote:
    > Having no mathematical skills or the required white brain cell*
    > activity to develop them
    > I have utterly failed to produce a tool that can convert small strings
    > into unsigned chars
    > of their binary equivalents.
    > For example a file containing (in ASCII):


    > 1 1010
    > 111 10


    > would become a file containing (as numeric values): 1 10 7 2


    > I've tried oktata and it required anding, oring and xoring everything
    > instead of straight
    > forward editing. It also suggested in the manual that that was the
    > traditional technique.


    I have no idea what 'oktata' is but an algorithm that takes a
    string representing a binary number like '1010' and coverts it
    to an unsigned integer is rather simple, not needing any and's,
    or's or xor's, just simple multiplication by 2 and adding 1.
    Here's some pseudo-code

    1) Store 0 somewhere
    2) Get the next character from the input
    3) If the character is not '0' or '1' goto 6
    3) Multiply the number you stored by 2
    4) If the character you read is '1' add 1 to the number you stored
    5) Goto 2
    6) Congrats, you're done and the number you stored is what you
    wanted to calculate, i.e. the numerical value of the string
    representing a binary number

    For the next number skip everything up to the next '1' or '0'
    and start again from 1.

    > So what tools (if any are there) for editing a binary by just...
    > editing it rather
    > than doing a heap of maths on all but the correct byte?


    What do you mean by "editing"? What exactly you want to achieve?

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  3. Re: What binary manipulation tools are there?

    RyanMcCoskrie wrote:
    > Having no mathematical skills or the required white brain cell*
    > activity to develop them
    > I have utterly failed to produce a tool that can convert small strings
    > into unsigned chars
    > of their binary equivalents.
    > For example a file containing (in ASCII):
    >
    > 1 1010
    > 111 10
    >
    > would become a file containing (as numeric values): 1 10 7 2
    >
    > I've tried oktata and it required anding, oring and xoring everything
    > instead of straight
    > forward editing. It also suggested in the manual that that was the
    > traditional technique.
    >
    >
    > So what tools (if any are there) for editing a binary by just...
    > editing it rather
    > than doing a heap of maths on all but the correct byte?


    Your use of "editing" is unclear to me. But if you just
    want to take strings of '0' and '1' characters representing
    numbers in binary notation and derive the numeric values from
    them, strtol() and strtoul() are your friends. Pay particular
    attention to the third argument.

    --
    Eric Sosman
    esosman@ieee-dot-org.invalid

  4. Re: What binary manipulation tools are there?

    On Tuesday 19 August 2008 00:28, RyanMcCoskrie wrote:

    > Having no mathematical skills or the required white brain cell*
    > activity to develop them
    > I have utterly failed to produce a tool that can convert small strings
    > into unsigned chars
    > of their binary equivalents.
    > For example a file containing (in ASCII):
    >
    > 1 1010
    > 111 10
    >
    > would become a file containing (as numeric values): 1 10 7 2


    This is probably slightly OT here, but there are various unix command line
    tools (like eg bc) that can do the job.
    Some shells (eg bash) even have built-in conversion capabilities.


  5. Re: What binary manipulation tools are there?

    I'm working on a 16 instruction virtual machine (don't expect anything
    instructions, it only works with unsigned chars and the second
    last instructions are input, output).

    Any way I need something to write programs with and crufting an
    assembler together would take much to long.

    re okteta: A combination hex editor and migraine inducer for KDE

    Thanks for the algorithm Jens, It makes more sense than adding
    powers of two to everything like I was trying.

  6. Re: What binary manipulation tools are there?

    In article
    <878d423d-4670-4817-94e9-bde82bd094d6@w24g2000prd.googlegroups.com>,
    RyanMcCoskrie wrote:

    > I'm working on a 16 instruction virtual machine (don't expect anything
    > instructions, it only works with unsigned chars and the second
    > last instructions are input, output).


    Then what does this have to do with *Unix* programming?

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  7. Re: What binary manipulation tools are there?

    Friedrich Kossebau (the creator of okteta) just asked me to post an
    explanation of how to use it properly on his (I assume Friedrich is
    a male name) behalf since he is without usenet acces :

    1. Create a new byte array (Ctrl-N)
    2. Switch value column to binary display (View->Value Coding->Binary)
    3. Set the active cursor to the value column (by clicking in there or
    using
    Shift-Tab).
    4. Enter the string, using or as separator. Straight
    forward,
    no?
    5. Switch value coding to Decimal (cmp. switching to binary before)
    6. Select all (Ctrl-a)
    7. File->Export...->Values

+ Reply to Thread