binary

Why do most languages not allow binary numbers?

Why do most computer programming languages not allow binary numbers to be used like decimal or hexadecimal? In VB.NET you could write a hexadecimal number like &H4 In C you could write a hexadecimal number like 0x04 Why not allow binary numbers? &B010101 0y1010 Bonus Points!... What languages do allow binary numbers? Edit Wo...

Interview Question 101 - Binary Number Interpretation

Pretend you're at an interview. The interviewer asks: What is the decimal value of this binary number? 10110101 What is the first thing you responsed with? ...

Tools to help reverse engineer binary file formats

What tools are available to aid in decoding unknown binary data formats? I know Hex Workshop and 010 Editor both support structures. These are okay to a limited extent for a known fixed format but get difficult to use with anything more complicated, especially for unknown formats. I guess I'm looking at a module for a scripting language...

C++ string to boolean array

I have a ~100 digit string which represents a number in base 10 that I want to convert to either a string representing the number in base 2, or a bool array which represents the number's digits in binary. I can do it easily in Java using BigInteger, but I'm not sure if there is an equivalent in C++. Function would be something like: s...

Use CDATA to store raw binary streams?

Instead of the overhead with saving binary as Base64, I was wondering if you could directly store double-byte binary streams into XML files, using CDATA, or commenting it out, or something? ...

MySQL binary against non-binary for hash IDs

Assuming that I want to use a hash as an ID instead of a numeric. Would it be an performance advantage to store them as BINARY over non-binary? CREATE TABLE `test`.`foobar` ( `id` CHAR(32) BINARY CHARACTER SET ascii COLLATE ascii_bin NOT NULL, PRIMARY KEY (`id`) ) CHARACTER SET ascii; ...

Binary data over serial terminal

My only way of communication with my embedded device is a serial port. By default, embedded Linux uses this port as a terminal. How do I disable this terminal and use the serial link to transfer binary data? I heard of commands like rx and tx but i cannot find them. I think I can just read() from and write() stuff to /dev/tty but I want...

Creating multiple numbers with certain number of bits set

Problem I need to create 32 Bit numbers (signed or unsigned doesn't matter, the highest bit will never be set anyway) and each number must have a given number of Bits set. Naive Solution The easiest solution is of course to start with the number of zero. Within a loop the number is now increased by one, the number of Bits is counted, ...

How can I output a number as a string of bits in C#?

In C#, how can I output a number as binary to the console? For example, if I have a uint with the value of 20, how can I print to the console: 00010100 (which is 20 in binary)? ...

What is the best format to store images in a database?

What is the best format to store images in a database, such as binary,base64...etc, for optimal speed/size. ...

LINUX: Is it possible to write a working program that does not rely on the libc library?

I wonder if I could write a program in the C-programming language that is executable, albeit not using a single library call, e.g. not even exit()? If so, it obviously wouldn't depend on libraries (libc, ld-linux) at all. ...

How do I add an attachment to an email using System.Net.Mail?

I have an excel document represented as a byte[] and I'm wanting to send it as an attachment in an email. I'm having a bit of trouble constructing the attachment. I can create an Attachment which has the following constructors: (Stream contentStream, ContentType contentType) (Stream contentStream, string name) (Stream contentStream, s...

Is it acceptable/good to store binaries in SVN?

We would like to share runtime project binary files. So every team member could take current working version. It is acceptable/good to store runtime binaries in the SVN? ...

How can I determine the content type of a file in .NET?

I'm given a filename and I have to be able to read it from disk and send its contents over a network. I need to be able to determine whether the file is text or binary so I know whether to use a StreamReader or BinaryReader. Another reason why I need to know the content type is because if it is binary, I have to MIME encode the data be...

Storing MySQL GUID/UUIDs

This is the best way I could come up with to convert a MySQL GUID/UUID generated by UUID() to a binary(16): UNHEX(REPLACE(UUID(),'-','')) And then storing it in a BINARY(16) Are there any implications of doing it this way that I should know of? ...

Read data with varying formats in C++

I'm creating my first real binary parser (a tiff reader) and have a question regarding how to allocate memory. I want to create a struct within my TiffSpec class for the IFD entries. These entries will always be 12 bytes, but depending upon the type specified in that particular entry, the values at the end could be of different types (or...

How to create BinaryArray in VbScript?

I want to manually create a binary script and then save it as binary file. I want to append all of the following bytes and create a binary file out of them. &HF0 &HF1 &HF2 I want to able to do something like this : Dim generateData(3) As Byte generateData(0) = &HFF generateData(1) = &HFE generateData(2) = &HFC But obviously As B...

How can I custom indent a file with vim ?

I recently read this article related to indenting source files in Vim . However , I would like to be able to custom indent some of them . Is there a way to specify which binary runs when I press = ? ...

Developing a (file) exchange format for java

I want to come up with a binary format for passing data between application instances in a form of POFs (Plain Old Files ;)). Prerequisites: should be cross-platform information to be persisted includes a single POJO & arbitrary byte[]s (files actually, the POJO stores it's names in a String[]) only sequential access is required shoul...

Why should I use a human readable file format?

Why should I use a human readable file format in preference to a binary one? Is there ever a situation when this isn't the case? EDIT: I did have this as an explanation when initially posting the question, but it's not so relevant now: When answering this question I wanted to refer the asker to a standard SO answer on why using a human...