binary

Is it safe to use -1 to set all bits to true?

I've seen this pattern used a lot in C & C++. unsigned int flags = -1; // all bits are true Is this a good portable way to accomplish this? Or is using 0xffffffff or ~0 better? ...

Ruby Iteration Question : Binary->Decimal Program

I am learning Ruby and thought of making a Binary->Decimal converter. It gets a binary string and converts to decimal equivalent. Is there a way to keep track of the current iteration step in ruby so that the variable 'x' can be removed? def convert(binary_string) decimal_equivalent = 0 x=0 binary_string.reverse.each_char...

The shortest Binary sequence to cover Dec numbers 0-99

Consider the set of strings S that contains the binary representation of the numbers 0 to 99. What is the shortest string T such that every element of S is a substring of T? ...

Check a webpage remotely to see if if its ASCII or Binary

Hello, Is it possible to check remotely (no local/FTP access) a URL to see if the webpage (file) was uploaded/created as binary or ascii? Thanks, Roy. ...

Efficiently convert between Hex, Binary, and Decimal in C/C++

I have 3 base representations for positive integer numbers: Decimal, in unsigned long variable (e.g. unsigned long int NumDec = 200). Hex, in string variable (e.g. string NumHex = "C8") Binary, in string variable (e.g. string NumBin = "11001000") I want to be able to convert between numbers in all 3 representations in the most effici...

How to separate content from a file that is a container for binary and other forms of content

I am trying to parse some .txt files. These files serve as containers for a variable number of 'children' files that are set off or identified within the container with SGML tags. With python I can easily separate the children files. However I am having trouble writing the binary content back out as a binary file (say a gif or jpg). ...

Binary word trees

I have barely squeaked by my last cs class and now I am in data structures. I am building a binary tree structure from scratch and I am a little confused on how the iterator will work. I understand how they work in double linked lists, but am not sure how this one will work................ thanks. ...

How do you count in another base?

Say I want to count in binary until I have the highest number a set number of bytes will hold, how could I do that? It feels like there should be a pretty simple way, I just don't know it. I googled but was surprised to not find any examples. For example, if I wanted to count to 1 byte I'd start with 00000001 add 1 and get 00000010, add...

read from binary file with variable length records

Hello, I have a binary file with variable length record that looks about like this: 12 economic10 13 science5 14 music1 15 physics9 16 chemistry9 17 history2 18 anatomy7 19 physiology7 20 literature3 21 fiction3 16 chemistry7 14 music10 20 literature1 The name of the course is the only variable length record in the f...

C++ STL's String eqivalent for Binary Data

I am writing a C++ application and I was wondering what the C++ conventional way of storing a byte array in memory. Is there something like a string, except specifically made for binary data. Right now I am using a *unsigned char** array to store the data, but something more STL/C++ like would be better. ...

How to edit raw PCM audio data without an audio library?

I'm interested in precisely extracting portions of a PCM WAV file, down to the sample level. Most audio modules seem to rely on platform-specific audio libraries. I want to make this cross platform and speed is not an issue, are there any native python audio modules that can do this? If not, I'll have to interpret the PCM binary. Whi...

Does Delphi sometimes revert text form files (DFM) to binary format?

Our Delphi 7 development team stores form files (dfm) in text mode, and uses a source control system (Subversion) to track changes. Sometimes, we noticed that a form file returned to binary format between revisions, causing diff tools like TortoiseMerge to complain. Using the Subversion change log, I can see that the DFM file was store...

Is there a function that returns the ASCII value of a character? (C++)

I need a function that returns the ASCII value of a character, including spaces, tabs, newlines, etc... On a similar note, what is the function that converts between hexadecimal, decimal, and binary numbers? ...

How to check if the binary representation of an integer is a palindrome?

How to check if the binary representation of an integer is a palindrome? ...

follow up email response to app rejection - iphone

Was wondering what is the correct protocal for responding to an app rejection follow up through email. I've included my response with my argument that states their "reasons" for rejection are wrong via email. I also made sure that i made the necessary changes to the app, to 1) ensure there are no more bugs and 2)make sure it's 3.0 compl...

Can I execute multiple instances of a Java class file?

I am thinking of executing multiple instances of same java binary (a socket application) with different configuration files (As a command line parameter). Does the JVM correctly handles this situation? In other words If I haven't any common resources (Files that can be locked etc.) will this approach make any problems? If so what are thi...

Finding binary chunk in a file

I have a chunk of fairly random binary data. I want to find where that chunk exists in a file, how many times it occurs, and at what byte (or sector) offsets. Any ideas on how to do that? Thanks, Justin ...

Easiest way to compare two Excel files in Java?

I'm writing a JUnit test for some code that produces an Excel file (which is binary). I have another Excel file that contains my expected output. What's the easiest way to compare the actual file to the expected file? Sure I could write the code myself, but I was wondering if there's an existing method in a trusted third-party library (...

In Java, can I define an integer constant in binary format?

Similar to how you can define an integer constant in hexadecimal or octal, can I do it in binary? I admit this is a really easy (and stupid) question. My google searches are coming up empty. ...

Reading binary file defined by a struct

Hi, Could somebody point me in the right direction of how I could read a binary file that is defined by a C struct? It has a few #define inside of the struct, which makes me thing that it will complicate things. The structure looks something like this: (although its larger and more complicated than this) struct Format { unsigned lon...