By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,796 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

Data Conversion

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
> 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?

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! =-----
Jul 17 '05 #2

P: n/a
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" <Ab***@SpamBusters.com> wrote in message
news:3f********@corp.newsgroups.com...
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?

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! =-----

Jul 17 '05 #3

P: n/a
Ahh, sounds to me like this person seeks a binary to decimal converter.

"Dillon Mantle" <di*****@dasolutions.co.za> wrote in message
news:z_CdnQr7ErBoD2CiRVn-

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

Jul 17 '05 #4

P: n/a
> Ahh, sounds to me like this person seeks a binary to decimal converter.

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

Rick - MVP
Jul 17 '05 #5

P: n/a
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message news:<rd********************@comcast.com>...
Ahh, sounds to me like this person seeks a binary to decimal converter.


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


Or one without the extra subtractions and exponentiations...

Function Bin2Dec(BinaryString As String) As Long
Dim x As Long
For x = Len(BinaryString) To 1 Step -1
Bin2Dec = Bin2Dec * 2 + CLng(Mid$(BinaryString, x, 1))
Next
End Function
Jul 17 '05 #6

P: n/a
> > > Ahh, sounds to me like this person seeks a binary to decimal
converter.

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


Or one without the extra subtractions and exponentiations...

Function Bin2Dec(BinaryString As String) As Long
Dim x As Long
For x = Len(BinaryString) To 1 Step -1
Bin2Dec = Bin2Dec * 2 + CLng(Mid$(BinaryString, x, 1))
Next
End Function


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(BinaryString As String) As Long
Dim x As Long
For x = 1 To Len(BinaryString)
Bin2Dec = Bin2Dec * 2 + CLng(Mid$(BinaryString, x, 1))
Next
End Function

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

Rick - MVP
Jul 17 '05 #7

P: n/a
"Bob Butler" <bu*******@earthlink.net> wrote
Ahh, sounds to me like this person seeks a binary to decimal converter.
Function Bin2Dec(BinaryString As String) As Long
Dim X As Integer
For X = 0 To Len(BinaryString) - 1
Bin2Dec = Bin2Dec + Val(Mid(BinaryString, _
Len(BinaryString) - X, 1)) * 2 ^ X
Next
End Function


Or one without the extra subtractions and exponentiations...

Function Bin2Dec(BinaryString As String) As Long
Dim x As Long
For x = Len(BinaryString) To 1 Step -1
Bin2Dec = Bin2Dec * 2 + CLng(Mid$(BinaryString, x, 1))
Next
End Function


Or one without multiplications or string lookups...

Function Bin2Dec(BinaryString 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! =-----
Jul 17 '05 #8

P: n/a
> > > > Ahh, sounds to me like this person seeks a binary to decimal
converter.
Function Bin2Dec(BinaryString As String) As Long
Dim X As Integer
For X = 0 To Len(BinaryString) - 1
Bin2Dec = Bin2Dec + Val(Mid(BinaryString, _
Len(BinaryString) - X, 1)) * 2 ^ X
Next
End Function


Or one without the extra subtractions and exponentiations...

Function Bin2Dec(BinaryString As String) As Long
Dim x As Long
For x = Len(BinaryString) To 1 Step -1
Bin2Dec = Bin2Dec * 2 + CLng(Mid$(BinaryString, x, 1))
Next
End Function


Or one without multiplications or string lookups...

Function Bin2Dec(BinaryString 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


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(BinaryString 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


Jul 17 '05 #9

P: n/a
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote
If I feed "1000" into your originally posted function, it returns 1. If I
feed it into the above revision, I get 8.

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! =-----
Jul 17 '05 #10

P: n/a

"Larry Serflaten" <Ab***@SpamBusters.com> wrote in message
news:3f********@corp.newsgroups.com...
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote
If I feed "1000" into your originally posted function, it returns 1. If I feed it into the above revision, I get 8.

Doh!

I tested it with 5! (101)

Thanks for the correction!

LFS


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
Jul 17 '05 #11

P: n/a
"Rick Rothstein" <ri************@NOSPAMcomcast.net> wrote in message news:<d9********************@comcast.com>...
<cut>
Your function has the same flaw as Bob's did... the loop
counter is backwards.


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!
Jul 17 '05 #12

P: n/a
> I tested it with 5! (101)

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

Rick - MVP
Jul 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.