binary

Pipe STDOUT/STDIN with two process and a web output stream in C#

I have two processes that I'd like to pipe together with C#, and then send the output of the second one directly to an HTTP output stream. In a command line, I can do this and it works perfectly (where "-" represents stdin/stdout): proc1 "file_to_input" - | proc2 - - My problem is connecting these two processes in C# and being able t...

sequential vs. binary search

Consider a file on disk containing 100 records. For both searches, what is the average number of comparisons needed to find a record in a file. number of comparisons if the record is not in the file the average number of comparisons if the record has a 68% chance of being in the file the number of disk accesses in the previous 3 quest...

Mysql binary storage problem

I'm hashing using sha256 and outputting it in binary, and storing it in Mysql's BINARY(32). echo $testsha256 = hash( 'sha256', "aKyAmNsb", true ); However, when I retrieve this value from the database, it's Different print_r(str_split($returnedpassword)); echo "<br>"; print_r(str_split($testsha256)); echo "<br>"; Array ( [0] ...

C: Building a byte

I have an array with 16 elements. I would like to evaluate these to a boolean 0 or 1 and then store this in 2 bytes so i can write to a binary file. How do I do this? ...

What is the proper way to replace very small portions of a binary file programmatically?

I have a game code (from ioquake3 project) that compiles part of gameplay binaries on the fly (the qvm system). Now, one could potentially speed it up by loading previously saved binaries of this operation (with any change-of-files precautions in place). But, pointers to functions saved in these binaries are not persistent through sess...

HTTP Headers for Unknown Content-Length

I am currently trying to stream content out to the web after a trans-coding process. This usually works fine by writing binary out to my web stream, but some browsers (specifically IE7, IE8) do not like not having the Content-Length defined in the HTTP header. I believe that "valid" headers are supposed to have this set. What is the pro...

Converting to Base 10

Question Let's say I have a string or array which represents a number in base N, N>1, where N is a power of 2. Assume the number being represented is larger than the system can handle as an actual number (an int or a double etc). How can I convert that to a decimal string? I'm open to a solution for any base N which satisfies the abov...

How do I convert from a decimal number to IEEE 754 single-precision floating-point format?

How would I go about manually changing a decimal (base 10) number into IEEE 754 single-precision floating-point format? I understand that there is three parts to it, a sign, a exponential, and a mantissa. I just don't completely understand what the last two parts actually represent. Thanks, Rob ...

Manipulating pixels using only toDataURL

The problem I have is this: I need to be able to dynamically tint an image using Javascript, but I cannot access pixel data via the canvas. I can, however, store the dataURL (or any other text-based data format) and include that with the code, manipulate that data, and then create an image object using that dataURL. My question is, ho...

How do you convert from IEEE 754 single-precision floating-point format to decimal?

I understand that the first bit is the sign and that the next 8 bits is the exponent. So in this example you would have 1.1001*2^-4 ? How do I then interpret this in decimal? 0 01111011 10010000000000000000000 ...

Converting an int to a binary string representation in Java?

What would be the best way (ideally, simplest) to convert an int to a binary string representation in Java? For example, say the int is 156. The binary string representation of this would be "10011100". ...

how to handle gitting of binaries, e.g. .mo files

Is there a simple way to handle binary files in git operations? I think my ideal in this case - 'merging' of .mo files (binary .po messages) - would be to give precedence to the newer file, copying it over the top of the older one. So can I configure git to do this or is it always going to be a manual exercise? ...

Algorithm for binary arithmetic in Java

On paper, binary arithmetic is simple, but as a beginning programmer, I'm finding it a little difficult to come up with algorithms for the addition, subtraction, multiplication and division of binary numbers. I have two binary numbers stored as strings, assume that any leading zeroes have been dropped. How would I go about performing th...

Problem to convert string binary (64 bits) to decimal (c++ in iphone)

Hi I have a problem converting a string binary to a decimal I was using bitset bitstring ="1011010001111111"; unsigned long binToDec( string bitstring){ bitset<32> dec (bitstring); return dec.to_ulong(); } All of this works fine, but !! the problem comes when i try to do the same with a bits string with more of 32 bits. I kn...

how to crate a PATCH file for the binary difference output file

hi i want to know how to create a PATCH for the difference file i got by comparing two banary files. $cmp -l > output file name i checked for text files 'diff" can be used to compare and generate a PATCH file $ diff -u oldFile newFile > mods.diff # -u tells diff to output unified diff format i want to apply the PATCH on the old...

Using Haskell's Parsec to parse binary files?

Parsec is designed to parse textual information, but it occurs to me that Parsec could also be suitable to do binary file format parsing for complex formats that involve conditional segments, out-of-order segments, etc. Is there an ability to do this or a similar, alternative package that does this? If not, what is the best way in Hask...

How to read file binary in C#?

I want to make a method that takes any file and reads it as an array of 0s and 1s, i.e. its binary code. I want to save that binary code as a text file. Can you help me? Thanks. ...

Examples of attoparsec in parsing binary file formats?

Previously attoparsec was suggested to me for parsing complex binary file formats. While I can find examples of attoparsec parsing HTTP, which is essentially text based, I cannot find an example parsing actual binary, for example, a TCP packet, or image file, or mp3. Can someone post some code or pointer to some code which does this usin...

dynamic array pointer to binary file

Hi guys, Know this might be rather basic, but I been trying to figure out how to one after create a dynamic array such as double* data = new double[size]; be used as a source of data to be kept in to a binary file such as ofstream fs("data.bin",ios:binary"); fs.write(reinterpret_cast<const char *> (data),size*sizeof(double)); Whe...

Uniform distribution of binary values in Matlab

I have a requirement for the generation of a given number N of vectors of given size each consistent of a uniform distribution of 0s and 1s. This is what I am doing at the moment, but I noticed that the distribution is strongly peaked at half 1s and half 0s, which is no good for what I am doing: a = randint(1, sizeOfVector, [0 1]); ...