binary

C# Binary Serialization

Hi all, I am trying to serialize and deserialize objects to/from a Byte array for network communication, I currently have an interface 'ISerialize'. However I got thinking there should be a more robust way to do this via reflection. I've looked around a little bit at doing this using BinaryFormater, but I can't see if it will give me t...

Search for Binary Pattern in C (Read buffered binary file)

Hey there. I'm trying to write a small program that will read the four following bytes after the last occurrence of "0xFF 0xC0 0x00 0x11" which can be converted easily to binary or decimal. The purpose is that the 2-5 bytes following the last occurrence of that hex pattern represent the width and height of a JPEG file. #include <stdio.h...

How are bits stored in memory? (In chunks? Can there be bits of multiple sizes stored toghether?)

I used to think that each memory location contains 8, 16, 32 or 64 bits. So 0101 would be stored in an 8 bit machine as 00000101 (sign extended if it was negative). This was all fine and dandy until I wrote a program in java out of curiosity to find out some more inner workings of this system. The method in question looks like this: p...

Opening file in another directory in C

How is this achieved? I want to use pFile = fopen( file, "rb" ); Where file is a char, string or long containing the literal text containing a local path to a binary file C:\Documents and Settings\Supernovah\Desktop\Supernovah.bin but of course that crashes. I am also interested in how to recur over the current directory in a port...

Working with binary data in PHP

Hello, here are 5 binary strings base64_encode()'ed wAD4Af8B/gHuA/4BzgP1A/8P/h//f/xv+z30D9IDSAE= AAAgCPgf/B/4H/w1+B74Gfg/+B/8P/4f/D/8HwABAAA= AAAAAMB/wP/A/8B/4HvAf+B/+n/3P/Y//z/4n4CDgAE= AAAAXcB/wH/Af8B/wHfAP+B/6H/xf+7//r/4f0CngFY= AAiwifAP+B/4D/gf8B74D/gd8V/4H/gP8B/8vwABAAA= AAAAAAAA/QD/Af4B/iP+A/wD/A/+//7/...

Encoding an integer in 7-bit format of C# BinaryReader.ReadString

C#'s BinaryReader has a function that according to MSDN, reads an integer encoded as "seven bit integer", and then reads a string with the length of this integer. Is there a clear documentation for the seven bit integer format (I have a rough understanding that the MSB or the LSB marks whether there are more bytes to read, and the rest ...

VBScript - image to binary

Hi to all, i'm not a VB programmer but i need a vbscript that convert image file (from local disk) to be converted to binary data and the passed to webservice. I realize how to pass data to webservice but i can't find how to convert the image file to binary data. I spend a lot of time to find some kind of solution but with no luck. Can ...

Problems loading bulk data in mysql using php.

I have a script that gets the raw binary image data via url request. It then takes the data and puts it into mysql. Pretty simple right? Well It's I'm inserting some 8,000 decent sized 600x400 jpegs and for some odd reason some of the images are getting cut off. Maybe the part of my script that iterates through each image it needs to ge...

MacPorts/Unix/bash question

I'm new to all things shell/binary, and was installing git (I understand scm is a good thing from being on SO). My internet hiccuped partway through, however, and the installation stalled. It interrupted a tar.gz download, and I don't know quite how to resume where it left off. Here's the output: computer:~ Alex$ sudo port install git...

Nonrestoring division for unsigned binary

I have tried to look online for a way to do a non-restoring division, but the explanation has still left me quite clueless. dividend = 0100 0011 1100 0000 quotient = 0110 0010 divisor is not given How do you figure out the total # of operations (ie. the number of subtractions, the number of additions performed)? ...

Sending part of byte array over the network using WCF

I have a byte array of some binary data that i need to send over the network using WCF and NetTcpBinding. My problem is that i need to send only the part of the array. Is there any way to do this, other than copying that part to a separate array, and sending that one. This extra copying degrades performance, and i would like to avoid it,...

How can you reverse engineer a binary thrift file?

I've been asked to process some files serialized as binary (not text/JSON unfortunately) Thrift objects, but I don't have access to the program or programmer that created the files, so I have no idea of their structure, field order, etc. Is there a way using the Thrift libraries to open a binary file and analyze it, getting a list of th...

Stream binary file from MySQL to download with PHP

I have Excel spreadsheets stored in a MySQL table longblob field. I need to retrieve this data and then stream it to the user as a downloadable file, preferably without writing it to disk first. Possible? Edit - Eh, just figured it out... Posted in answer below. ...

Write Binary File

I am reading data from an IPhone App that uses http POST to transfer the image to the Server I can read this into a an binary and it does write to a file (See below) the issue I have is when I open the image it fails. You can see the code from the Iphone on this post: http://stackoverflow.com/questions/1547967/asp-http-post-read-data C...

Does code in header file increases binary size?

Hello there Consider this: class Foo{ void func1(){ /*func1 code*/ } void func2(){ /*func2 code*/ } }; Case 1: class Foo in Foo.h Case 2: class Foo nicely seperated among Foo.h and Foo.cpp Various other cpp files include Foo.h My question is...Will Case 1 lead to a bigger binary...

R: Occurrence times -> binary sequence?

What are the better options to convert a non-decreasing seq of occurrence times to a 0-1 seq? Thanks. d<-c(3,5,9,12,15); c(rep(0,d[1]-1),1,unlist(rbind(mapply(rep,0,diff(d)-1),1))) ...

Binary Searching

Hi So, I want to understand more about binary searching, cause I don't really understand. Binary search requires a precondition that an array is sorted. I got that right? It seems like a method should check this precondition and throw an exception if it is not met. But, why is checking the precondition a bad idea? ...

Converting a decimal number into binary

I am currently reading Charles Petzold's book 'Code'. In it he explains how to convert a decimal number into binary using the following template: [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] ÷128 ÷64 ÷32 ÷16 ÷8 ÷4 ÷2 ÷1 [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] In th...

Python convert hex to float

How to convert the following hex string to float (single precision 32-bit) in python? "41973333" -> 1.88999996185302734375E1 "41995C29" -> 1.91700000762939453125E1 "470FC614" -> 3.6806078125E4 Thanks ...

How do I convert a large array of 8 bit binary values in MATLAB?

This is a follow-up question to another SO question of mine. I have a large array of 8 bit binary values that I want to convert back to uint8. I have used Amro's lookupTable solution from the previous question. Now I want to do the reverse. I wanted to do a lookup table but sadly I am unable to. What I managed to do is the following: ...