Questions tagged [binary-data]

Binary-data is information stored using a two character alphabet (typically written using 0 and 1)

Binary Data is information which is stored using a two character alphabet. For example, the number 42 could be stored as its base-2 representation: 101010.

In modern computers, almost all data is ultimately represented in binary form.

To be useful, the writer and reader of binary data must have a pre-agreed format (e.g. a file consisting of a 32-bit, two's compliment integer followed by three IEEE 754 floating point numbers).

The term is usually used to distinguish data stored in this way against data stored using a textual encoding. For example, the digits of 42 in base-10 (4 and 2) may be represented using ASCII as 00110100 and 00110010. Whether this is considered binary data or not depends on the task at hand; a chat client would consider messages as textual data, but the communication protocol it is built on may consider the same messages as arbitrary binary data.

1585 questions
10
votes
1 answer

Output binary data from CGI in Python 3

This question is related to this one. I was having no problems while printing raw binary data from a CGI script in Python 2, for example: #!/usr/bin/env python2 import os if __name__ == '__main__': with open(os.path.abspath('test.png'), 'rb')…
astrojuanlu
  • 6,744
  • 8
  • 45
  • 105
10
votes
3 answers

ByteStrings in Haskell: should I use Put or Builder?

I'm confused as to what the Put monad offers over using Builder directly, in Data.Binary. I read the Binary Generation section of Dealing with Binary data, and it seems to assume that you should use Put, but it's pretty short doesn't explain…
mk12
  • 25,873
  • 32
  • 98
  • 137
9
votes
3 answers

Reverse engineering a statistics data file from my insulin pump controller

This may or may not be a grey area subject, though my intentions are certainly not, so my intention is not to stir up an ethical debate on the topic of reverse engineering. I'm a type 1 diabetic currently undergoing pump therapy. I'm an OmniPod…
mwilliams
  • 9,946
  • 13
  • 50
  • 71
9
votes
3 answers

How to store videos in a PostgreSQL database?

I am storing image files (like jpg, png) in a PostgreSQL database. I found information on how to do that here. Likewise, I want to store videos in a PostgreSQL database. I searched the net - some say one should use a data type such as bytea to store…
sat
  • 14,589
  • 7
  • 46
  • 65
9
votes
1 answer

Compile a binary file for linking OSX

I'm trying to compile a binary file into a MACH_O object file so that it can be linked it into a dylib. The dylib is written in c/c++. On linux the following command is used: ld -r -b binary -o foo.o foo.bin I have tried various option on OSX but to…
Satpal
  • 309
  • 2
  • 8
9
votes
5 answers

C#/.NET - Custom Binary File Formats - Where to Start?

I need to be able to store some data in a custom binary file format. I've never designed my own file format before. It needs to be a friendly format for traveling between the C#, Java and Ruby/Perl/Python worlds. To start with the file will consist…
BuddyJoe
  • 69,735
  • 114
  • 291
  • 466
9
votes
2 answers

Convert a bytea into a binary string

I need to decode a base64 string and take a chunk of binary. Is there a SQL function in Postgres to simply convert a bytea into a binary string representation? (Like "00010001010101010".)
GPif
  • 543
  • 2
  • 6
  • 22
9
votes
1 answer

How transform a dart's ByteData into a String?

I am reading a binary file and want to transform it into a String. How do I do it in Dart?
Daniel Oliveira
  • 8,053
  • 11
  • 40
  • 76
9
votes
2 answers

Framework for building structured binary data parsers?

I have some experience with Pragmatic-Programmer-type code generation: specifying a data structure in a platform-neutral format and writing templates for a code generator that consume these data structure files and produce code that pulls raw bytes…
John
  • 15,990
  • 10
  • 70
  • 110
9
votes
5 answers

Storing a binary hash value in a Django model field

I have a twenty byte hex hash that I would like to store in a django model. If I use a text field, it's interpreted as unicode and it comes back garbled. Currently I'm encoding it and decoding it, which really clutters up the code, because I have…
mbarkhau
  • 8,190
  • 4
  • 30
  • 34
9
votes
2 answers

Using Scikit-learn to determine feature importances per class in a RF model

I have a dataset which follows the one-hot encoding pattern and my dependent variable is also binary. The first part of my code lists the important variables for the entire dataset. I used the method as mentioned in this stackoverflow post, "Using…
9
votes
2 answers

How to execute a command for each loop in awk?

I'm using awk to split a binary stream and I can get each part into a for loop like this. for(i=1;i<=NF;i++) I don't want to convert each field to text or arguments, but simply pass it directly to a command. I'm trying to find something like…
akula1001
  • 4,576
  • 12
  • 43
  • 56
9
votes
2 answers

Reading an InputStream into a Data object

In Swift 3.x, we usually handle binary data using Data; from it you can generate most other important types, and there are useful functions on it. But how do I create a Data from an InputStream? Is there a nice way?
Raphael
  • 9,779
  • 5
  • 63
  • 94
9
votes
3 answers

Fast way to read interleaved data?

I've got a file containing several channels of data. The file is sampled at a base rate, and each channel is sampled at that base rate divided by some number -- it seems to always be a power of 2, though I don't think that's important. So, if I have…
Nate
  • 4,561
  • 2
  • 34
  • 44
9
votes
5 answers

How to print float value from binary file in shell?

I've binary file consisting double float (8 bytes) or just float (4 bytes) value which was generated in the following way: $ python -c $'from struct import pack\nwith open("file.bin", "wb") as f: f.write(pack("
kenorb
  • 155,785
  • 88
  • 678
  • 743