Question

I wanted to know what the difference is between binary format and ASCII format. The thing is I need to use PETSc to do some matrix manipulations and all my matrices are stored in text files.

PETSc has different set of rules for dealing with these formats. I don't know what these formats are, let alone what format my text file is.

Is there a way to convert one format to another?

This is an elementary question; a detailed answer will really help me in understanding this.

Was it helpful?

Solution

To answer your direct question, the difference between ASCII and binary is semantics.

ASCII is binary interpreted as text. Only a small subset of binary code can be interpreted as intelligible characters (decimal 32-126) everything else is either a special character (such as a line feed or a system bell or something else entirely.) Larger characters can be letters in other alphabets.

You can interpret general binary data as ASCII format, but if it's not ASCII text it may not mean anything to you.

As a general rule of thumb, if you open your file in a text editor (such as notepad, not such as microsoft word) and it seem to consist entirely of letters or primarily of letters, numbers, and spaces, then your file can probably be safely interpreted as ASCII. If you open your file in your text editor and it's noise it's probably needs to be interpreted as raw binary.

I am not very familiar with the program you're asking about, were I in your situation I would consult the documentation of the program to figure out what format the "binary" data stream is supposed to be in. There should be a detailed description or an included utility for generating your binary data. If you generated the data yourself it's probably in ASCII format.

OTHER TIPS

If your matricies are in text files, and your program only reads from binary files, you are probably out of luck.

Binary formats are just the raw bytes of whatever data structure it uses internally (or a serialization format).

You have little hope of turning text to binary without the help of the program itself.

Look for a import format if the program has one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top