Data Conversion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dillon Mantle

    #1

    Data Conversion

    HI All

    Does any one know how to convert a binary file into a readable (by human)
    file? Its from a bin file, has addresses and stuff which I can work out...
    but how do you do the actual conversion?

    --
    Regards
    Dillon Mantle
    Different Angle Solutions
    072 300 0206


  • Larry Serflaten

    #2
    Re: Data Conversion

    > Does any one know how to convert a binary file into a readable (by human)[color=blue]
    > file? Its from a bin file, has addresses and stuff which I can work out...
    > but how do you do the actual conversion?[/color]


    Thats like asking how to convert a book into something human readable.
    The book is already human readable, unless the text it contains is not words,
    but a bunch of random characters.

    If the file is text, no conversion is necessary. If the file is not text, then
    it will not be readable unless you know how to decypher its contents.
    For example, how do you make a picture file, human readable? It does not
    contain text, so you'll never get meaningful text from it.

    If the file is encrypted text, then you need to know the decryption algorithm
    to get the text back. No one here can tell you which algorithm to use, you need
    to find out what needs to be done.

    LFS




    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

    Comment

    • Dillon Mantle

      #3
      Re: Data Conversion

      Okay, let me be a little more specific.

      The binary data is pulled from a piece of sporting equipment. The memory
      extends from 0 to 1A6F, which is 564 data points at 12 bytes each. It is all
      numbers, set format as below

      interval type 1 byte 0 = distance, 1 = time, 2 =
      stroke
      time (1/64 sec interval) 3 bytes (72 hours)
      distance 3 bytes (1.6+ million m by 1/16)
      null byte 1 byte
      avg stroke rate 2 bytes (0-255 by 1/256)
      number of strokes 2 bytes (65000)

      I can work out the memory bits, its just how do you convert "00000001" into
      "1"

      --
      Regards
      Dillon Mantle
      Different Angle Solutions
      072 300 0206
      "Larry Serflaten" <Abuse@SpamBust ers.com> wrote in message
      news:3ffd7bd9_3 @corp.newsgroup s.com...[color=blue][color=green]
      > > Does any one know how to convert a binary file into a readable (by[/color][/color]
      human)[color=blue][color=green]
      > > file? Its from a bin file, has addresses and stuff which I can work[/color][/color]
      out...[color=blue][color=green]
      > > but how do you do the actual conversion?[/color]
      >
      >
      > Thats like asking how to convert a book into something human readable.
      > The book is already human readable, unless the text it contains is not[/color]
      words,[color=blue]
      > but a bunch of random characters.
      >
      > If the file is text, no conversion is necessary. If the file is not text,[/color]
      then[color=blue]
      > it will not be readable unless you know how to decypher its contents.
      > For example, how do you make a picture file, human readable? It does not
      > contain text, so you'll never get meaningful text from it.
      >
      > If the file is encrypted text, then you need to know the decryption[/color]
      algorithm[color=blue]
      > to get the text back. No one here can tell you which algorithm to use,[/color]
      you need[color=blue]
      > to find out what needs to be done.
      >
      > LFS
      >
      >
      >
      >
      > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
      > http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
      > -----== Over 100,000 Newsgroups - 19 Different Servers! =-----[/color]


      Comment

      • CajunCoiler \(http://www.cajuncoiler.tk\)

        #4
        Re: Data Conversion

        Ahh, sounds to me like this person seeks a binary to decimal converter.

        "Dillon Mantle" <dillonm@dasolu tions.co.za> wrote in message
        news:z_CdnQr7Er BoD2CiRVn-[color=blue]
        >
        > I can work out the memory bits, its just how do you convert "00000001"[/color]
        into[color=blue]
        > "1"[/color]


        Comment

        • Rick Rothstein

          #5
          Re: Data Conversion

          > Ahh, sounds to me like this person seeks a binary to decimal converter.

          Function Bin2Dec(BinaryS tring As String) As Long
          Dim X As Integer
          For X = 0 To Len(BinaryStrin g) - 1
          Bin2Dec = Bin2Dec + Val(Mid(BinaryS tring, _
          Len(BinaryStrin g) - X, 1)) * 2 ^ X
          Next
          End Function

          Rick - MVP


          Comment

          • Bob Butler

            #6
            Re: Data Conversion

            "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message news:<rdKdndf4l tfaMGCiRVn-hQ@comcast.com> ...[color=blue][color=green]
            > > Ahh, sounds to me like this person seeks a binary to decimal converter.[/color]
            >
            > Function Bin2Dec(BinaryS tring As String) As Long
            > Dim X As Integer
            > For X = 0 To Len(BinaryStrin g) - 1
            > Bin2Dec = Bin2Dec + Val(Mid(BinaryS tring, _
            > Len(BinaryStrin g) - X, 1)) * 2 ^ X
            > Next
            > End Function[/color]

            Or one without the extra subtractions and exponentiations ...

            Function Bin2Dec(BinaryS tring As String) As Long
            Dim x As Long
            For x = Len(BinaryStrin g) To 1 Step -1
            Bin2Dec = Bin2Dec * 2 + CLng(Mid$(Binar yString, x, 1))
            Next
            End Function

            Comment

            • Rick Rothstein

              #7
              Re: Data Conversion

              > > > Ahh, sounds to me like this person seeks a binary to decimal
              converter.[color=blue][color=green]
              > >
              > > Function Bin2Dec(BinaryS tring As String) As Long
              > > Dim X As Integer
              > > For X = 0 To Len(BinaryStrin g) - 1
              > > Bin2Dec = Bin2Dec + Val(Mid(BinaryS tring, _
              > > Len(BinaryStrin g) - X, 1)) * 2 ^ X
              > > Next
              > > End Function[/color]
              >
              > Or one without the extra subtractions and exponentiations ...
              >
              > Function Bin2Dec(BinaryS tring As String) As Long
              > Dim x As Long
              > For x = Len(BinaryStrin g) To 1 Step -1
              > Bin2Dec = Bin2Dec * 2 + CLng(Mid$(Binar yString, x, 1))
              > Next
              > End Function[/color]

              Yes, you could approach it that way too. (Remember, I was a math major in
              college... I **like** using lots of the math operations in my
              calculations.<g >)

              However, you need to change the direction through the For-Next loop to this

              Function Bin2Dec(BinaryS tring As String) As Long
              Dim x As Long
              For x = 1 To Len(BinaryStrin g)
              Bin2Dec = Bin2Dec * 2 + CLng(Mid$(Binar yString, x, 1))
              Next
              End Function

              The least significant bit of a binary string is at the right.

              Rick - MVP


              Comment

              • Larry Serflaten

                #8
                Re: Data Conversion

                "Bob Butler" <butlerbob@eart hlink.net> wrote
                [color=blue][color=green][color=darkred]
                > > > Ahh, sounds to me like this person seeks a binary to decimal converter.[/color][/color][/color]
                [color=blue][color=green]
                > > Function Bin2Dec(BinaryS tring As String) As Long
                > > Dim X As Integer
                > > For X = 0 To Len(BinaryStrin g) - 1
                > > Bin2Dec = Bin2Dec + Val(Mid(BinaryS tring, _
                > > Len(BinaryStrin g) - X, 1)) * 2 ^ X
                > > Next
                > > End Function[/color]
                >
                > Or one without the extra subtractions and exponentiations ...
                >
                > Function Bin2Dec(BinaryS tring As String) As Long
                > Dim x As Long
                > For x = Len(BinaryStrin g) To 1 Step -1
                > Bin2Dec = Bin2Dec * 2 + CLng(Mid$(Binar yString, x, 1))
                > Next
                > End Function[/color]

                Or one without multiplications or string lookups...

                Function Bin2Dec(BinaryS tring As String) As Long
                Dim x As Long
                Dim Bin() As Byte
                Bin = BinaryString
                For x = UBound(Bin) - 1 To 0 Step -2
                Bin2Dec = Bin2Dec + Bin2Dec + (Bin(x) And 1)
                Next
                End Function

                LFS




                -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                Comment

                • Rick Rothstein

                  #9
                  Re: Data Conversion

                  > > > > Ahh, sounds to me like this person seeks a binary to decimal
                  converter.[color=blue]
                  >[color=green][color=darkred]
                  > > > Function Bin2Dec(BinaryS tring As String) As Long
                  > > > Dim X As Integer
                  > > > For X = 0 To Len(BinaryStrin g) - 1
                  > > > Bin2Dec = Bin2Dec + Val(Mid(BinaryS tring, _
                  > > > Len(BinaryStrin g) - X, 1)) * 2 ^ X
                  > > > Next
                  > > > End Function[/color]
                  > >
                  > > Or one without the extra subtractions and exponentiations ...
                  > >
                  > > Function Bin2Dec(BinaryS tring As String) As Long
                  > > Dim x As Long
                  > > For x = Len(BinaryStrin g) To 1 Step -1
                  > > Bin2Dec = Bin2Dec * 2 + CLng(Mid$(Binar yString, x, 1))
                  > > Next
                  > > End Function[/color]
                  >
                  > Or one without multiplications or string lookups...
                  >
                  > Function Bin2Dec(BinaryS tring As String) As Long
                  > Dim x As Long
                  > Dim Bin() As Byte
                  > Bin = BinaryString
                  > For x = UBound(Bin) - 1 To 0 Step -2
                  > Bin2Dec = Bin2Dec + Bin2Dec + (Bin(x) And 1)
                  > Next
                  > End Function[/color]

                  Am I the one who is remember the binary number system incorrectly? Isn't the
                  least significant bit written on the right? For example, isn't 8 written as
                  1000 in binary? Your function has the same flaw as Bob's did... the loop
                  counter is backwards. I think your function should be...

                  Function Bin2Dec(BinaryS tring As String) As Long
                  Dim X As Long
                  Dim Bin() As Byte
                  Bin = BinaryString
                  For X = 0 To UBound(Bin) - 1 Step 2
                  Bin2Dec = Bin2Dec + Bin2Dec + (Bin(X) And 1)
                  Next
                  End Function

                  If I feed "1000" into your originally posted function, it returns 1. If I
                  feed it into the above revision, I get 8.

                  Rick - MVP




                  Comment

                  • Larry Serflaten

                    #10
                    Re: Data Conversion

                    "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote
                    [color=blue]
                    > If I feed "1000" into your originally posted function, it returns 1. If I
                    > feed it into the above revision, I get 8.[/color]


                    Doh!

                    I tested it with 5! (101)

                    Thanks for the correction!

                    LFS






                    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
                    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
                    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----

                    Comment

                    • Steve Gerrard

                      #11
                      Re: Data Conversion


                      "Larry Serflaten" <Abuse@SpamBust ers.com> wrote in message
                      news:3fff19f6_7 @corp.newsgroup s.com...[color=blue]
                      > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote
                      >[color=green]
                      > > If I feed "1000" into your originally posted function, it returns 1.[/color][/color]
                      If I[color=blue][color=green]
                      > > feed it into the above revision, I get 8.[/color]
                      >
                      >
                      > Doh!
                      >
                      > I tested it with 5! (101)
                      >
                      > Thanks for the correction!
                      >
                      > LFS
                      >
                      >[/color]

                      That is so classic, you should save it for a text book...
                      Now, how about a version without the pesky addition or that annoying For
                      loop?
                      :)
                      Steve


                      Comment

                      • Bob Butler

                        #12
                        Re: Data Conversion

                        "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message news:<d9qdnXMuR KRHn2Ki4p2dnA@c omcast.com>...
                        <cut>[color=blue]
                        > Your function has the same flaw as Bob's did... the loop
                        > counter is backwards.[/color]

                        D'oh!

                        that's what I get for air coding and not trying it; I took your
                        original and reversed the loop to get rid of the subtraction and then
                        decided to change the exponentiation to multiplication and overlooked
                        the fact that that meant I needed to re-reverse the loop!

                        Comment

                        • Rick Rothstein

                          #13
                          Re: Data Conversion

                          > I tested it with 5! (101)

                          ROTFL... We've all been there and done that too Larry.

                          Rick - MVP


                          Comment

                          Working...