binary

Searching byte[]

Searching for a string within a string is extremely well supported in .NET but what do you do when the data you need to search isn't a string? I have binary data arriving in regular chunks via a NetworkStream. Packets are binary but they all start with a signature sequence of bytes. I accumulate the chunks into a larger buffer and look ...

How can I unpack binary hex formatted data in Python?

Using the PHP pack() function, I have converted a string into a binary hex representation: $string = md5(time); // 32 character length $packed = pack('H*', $string); The H* formatting means "Hex string, high nibble first". To unpack this in PHP, I would simply use the unpack() function with the H* format flag. How would I unpack thi...

I can read a binary field in MS SQL server 2005

Hi, I try to read a binary field in database ( Project Server 2007; dbo.MSP_CALENDAR ). MS don't implemante any fonction into PSI. Everybody have a suggestion? Thanks in advance SPo In Database Piblished, in table dbo.MSP_CALENDAR, i found a field named CAL_DATA, this field is BINARY. I try to CAST or CONVERT this field into s...

Object(Output|Input)Stream binary protocol

I was wondering if anyone had some resources that describe the binary protocol used by ObjectOutputStream. I realize of course that objects themselves can specify what their data by implementing the Externalizable interface, so I guess I'm looking more toward the structure of the object graph - the metadata if you will. I am writing a C...

Suggested reading for BITS/Bytes and sample code to perform operations etc.

Hi, Need a refresher on bits/bytes, hex notation and how it relates to programming (C# preferred). Looking for a good reading list (online preferably). ...

need access to Class Object via Function Pointer - Binary Search Tree Class Creation Related

Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left != NULL) inOrder((*inOrderPtr)(this->left)); inOrderPtr(this->data); if(this->right != NULL) inOrder((*inOrderPtr)(this->right)); } Here is the function. Now this is obviously wrong. Th...

Is there any way of reducing the dump file size of a Sybase database?

When I dump a Sybase database, it doesn't seem to matter whether there's data in the tables or not, the file size is the same. I've been told that this is down to the fact that my dump file is binary and not logical, so the file of the dump file is based on the allocated size of the database. I know that Oracle can use logical dump files...

C# BinaryFormatter - How can I find out the class of the binary data?

I want to deserialize an object but don't know the class up front. So, consider the following code... IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream("MyFile.bin", FileMode.Open, FileAccess.Read, FileShare.Read); MyObject obj = (MyObject)formatter.Deserialize(stream); What could I do if I don't know the c...

What's the simplest way of adding one to a binary string in Perl?

I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-order, subnet. I'm trying to add them together and add one to get the first IP in the subnet. To get the ASCII representation, I can do inet_ntoa($ip&$netmask...

C# - Optimising binary serialization for multi-dimensional generic arrays

I have a class that I need to binary serialize. The class contains one field as below: private T[,] m_data; These multi-dimensional arrays can be fairly large (hundreds of thousands of elements) and of any primitive type. When I tried standard .net serialization on an object the file written to disk was large and I think .net is stori...

What knowledge do you need to create a patch for your game or application?

I've always been mystified how software vendors can ship their application or game, and then later provide a different set of executables that change the behaviors of the previous build. How is this done? Do the original application and the patch have to adhere to some kind of rule? Or does the patch crawl into the original executable an...

Save PDF to A SQL Binary (.Net)

I am using a ASP/.Net webpage and i want to upload a pdf file into a SQL Database as a binary I am uping the build in upload control, can you please suggest a way of doing this. I also need to no how to read the pdf back and display it in a web browser. I will be using linq to upload and query my sql database. ...

C++ Binary Search Tree Recursive search function

template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x); } template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) { if (root == NULL) return false; else { if (root->data == x) return true; else if(root->data < x) search(root->left, x); ...

Binary Search Tree Deletion (Inorder Pred method) C++

Ok so I thought it was fixed, but I'm getting totally inconsistent results. I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure where else to go template...

Binary Search or Btree index Update problem

Imagine that you are handed a new book everyday from an author. The book is a work in progress. He does not tell you what he has changed or added. Your job is to identify the changes and additions, and pass ONLY these along to the publisher (who does not have time to read the entire book everyday) For the purposes of this problem, the ...

How is "20" and 20 considered equal in JavaScript?

I understand that using the "===" compares type, so running the following code results in "not equal" because it's comparing a number type to a string type. var a = 20; var b = "20"; if (a === b) { alert("They are equal"); } else { alert("They are not equal"); } But I dont understand how using the "==" to compa...

Extracting a bit-field from a signed number

Hello, I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ? For positive numbers it is trivially true, and it seems t...

Help me write a binary search for boundary values (extracting sub lists)

Let's say I have an array of lots of values (C++ syntax, sorry): vector<double> x(100000); This array is sorted such that x[n] > x[n-1]. I would like a function to retrieve an array of all values in the range [a, b] (that's inclusive). Some interface like: void subarray(const double a, const double b, vector<double> &sub) { ... ...

Is the binary data I convert to a Short valid?

Howdy, I am reading a binary log file produced by a piece of equipment. I have the data in a byte[]. If I need to read two bytes to create a short I can do something like this: short value = (short)(byte[1] << 8); value += byte[2]; Now I know the value is the correct for valid data. How would I know if the file was messed up...

Seen this binary date format?

3/10/2008 = 1822556159 2/10/2008 = 1822523391 1/10/2008 = 1822490623 30/09/2008 = 1822392319 29/09/2008 = 1822359551 This is all the information that I know at the current time. Dates increment by 32768 except when changing month when the increment is 32768 x 2 (65536). Has anyone seen this binary date format and how can I extrac...