LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-25-2015, 10:38 AM   #1
AlexBB
Member
 
Registered: Mar 2014
Posts: 432

Rep: Reputation: Disabled
ASCII vs. binary files


Trying to work with gnuplot in Ubuntu 12.04 I run into confusing comments about binary vs. ASCII files. Take this as an example for instance. Looking for a good explanation I open this link. It is an outstanding sample of confusion and obfuscation. My own understanding is that binary is an executable file and ASCII is a source file. With gnuplot it is all upside down. I am confused.

Thanks,- A.

Last edited by AlexBB; 01-25-2015 at 01:41 PM.
 
Old 01-25-2015, 11:24 AM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
A binary file is not nessasarily an eqxecutable file for instance a jpeg file is a binary file but is not executable, and xpm file for instance is an ascii representation of an image so good for humans!
 
1 members found this post helpful.
Old 01-25-2015, 11:26 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Binary is any file that contains values in their internal form. Thus the number one in a file is stored as 4 bytes: 0,0,0,1. Floating point values get hard to read... (there are 4 byte float, 8 byte float, and if you work with some controllers there are 3 byte floats as well). This also applies to structures of values. The only thing present is a sequence of bytes.

ASCII is a binary file with data encoded using the ASCII character set (see "man ascii"). As this is very nearly a universally recognized coding, the file can be read by any system. Numbers in ascii are encoded into bytes, but because they are encoded, they take up more space. The only values used for a "1" is hex value 30, and that occupies an entire byte. (nice for small numbers, but to represent 30,000 requires 5 bytes of ascii, but only 2 bytes in binary (a "C" short), or 4 bytes if it is an integer. It gets even worse with floating point values. A 10,000 in binary float only needs 4 bytes - but five in ASCII - and there are multiple formats for floating values (exponetial/scientific, thus 10,000 = 1.0E4, and something like 19,543.25 = 1.954325E4, and 8 byte floats are even longer (roughly double, And I didn't even include the +/- signs on both the mantissa and exponent).

A binary file can contain an executable, but it doesn't have to.

One of the reasons binary files get used for data (at least when used on the same system) is that number conversions are SLOW. Not unreasonable for several hundred values (even several thousand). But the encoding/decoding steps add thousands of instructions per value, and that adds up when it comes to millions of numbers.

A binary file MAY be taken from system to system - but the system that reads it must use (or be able to convert) the exact format used for that file. If the file must be converted, then again you are back to a slow operation.

For most purposes, ASCII is more efficient - as it allows anyone to read the file (even using eyeballs on a display) without having to go through efforts at conversion.
 
2 members found this post helpful.
Old 01-25-2015, 11:31 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,928

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
The first link does not work for me. In a nutshell all files are binary. ASCII files aka text files just use ASCII characters. A binary file also contains non ASCII characters but is not necessarily executable.

Data stored in a database like mysql is binary but not executable. Spreadsheet files. Word processing files etc are also binary files. Make sense?
 
1 members found this post helpful.
Old 01-25-2015, 01:47 PM   #5
AlexBB
Member
 
Registered: Mar 2014
Posts: 432

Original Poster
Rep: Reputation: Disabled
Thanks for contributing. Sorry for the broken link in the OP. I corrected it but now it opens a whole page of gnuplot samples and I forgot which one I used to quote the comparison (could be this one). I think it was one of 3D plots. For the most part I know what has been posted. My major question actually was related to gnuplot. How do the binary data files look (extension, etc) in reference to gnuplot? How are they used? The gnuplot documentation is atrocious.

Last edited by AlexBB; 01-25-2015 at 02:29 PM.
 
Old 01-25-2015, 05:51 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
If as you say your problem is with gnuplot in particular I would suggest you mark this thread solved as the question you asked has been resonably answered and start a new thread in the software forum but be more specific about what your problem is with gnuplot, always take a minute to think about what forum you are starting a new thread in before you start it, you may consider yourself a newbie but that does not neccaserily mean you need to ask your question in the newbie forum.
 
Old 01-25-2015, 07:07 PM   #7
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
Posts: 4,493

Rep: Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635Reputation: 635
Check page 74 in this manual: www.gnuplot.info/docs_4.6/gnuplot.pdf

It explains the binary format and the command to use when displaying files in binary format.

There is no special extension needed (extensions are menaingless in Linux).

jlinkels

Last edited by jlinkels; 01-25-2015 at 07:08 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Binary to Ascii Conversion Problem towhidgrep Programming 3 11-18-2011 07:24 PM
Conversion of binary to ascii file HARIKHK Linux - Newbie 4 11-17-2011 11:33 AM
Extracting ASCII strings from a Binary files poorrej Linux - Newbie 2 10-31-2008 04:38 AM
ASCII vs Binary the_imax General 4 12-25-2004 11:35 AM
Converting ASCII to Binary? Darx Linux - Software 0 04-08-2004 11:43 AM


All times are GMT -5. The time now is 06:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration