binary-data

Binary Numbers what is the solution V2 [closed]

五迷三道 提交于 2019-12-13 09:57:13
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . Does anyone know how I can solve this problem ? any help would be great...... i cant seem to get my head around it. As you know Binary can only be either 1 or 0 Say you had a 8 digit Binary number like a byte >>>

Pass binary data from C to C# through the console

こ雲淡風輕ζ 提交于 2019-12-13 02:36:47
问题 I have two applications, one written in C and the other one in C#, which talk through console string messages. They both wait until the other sends a string message. Now I want that at a certain moment the C application sends an image in binary format through the same console I/O "channel" and that the C# application recieves it and uses it as an image to display. I know it is possible, see: C/C++: is it possible to pass binary data through the console?. I have access to the source code of

Unexpected “padding” in a Fortran unformatted file

三世轮回 提交于 2019-12-13 02:29:06
问题 I don't understand the format of unformatted files in Fortran. For example: open (3,file=filename,form="unformatted",access="sequential") write(3) matrix(i,:) outputs a column of a matrix into a file. I've discovered that it pads the file with 4 bytes on either end, however I don't really understand why, or how to control this behavior. Is there a way to remove the padding? 回答1: For unformated IO, Fortran compilers typically write the length of the record at the beginning and end of the

Convert from hex-encoded CLOB to BLOB in Oracle

南楼画角 提交于 2019-12-12 17:55:39
问题 I have some large binary content in hex form stored in a CLOB and want to convert that to a BLOB where the hex code is actual binary byte encoding: DECLARE -- This would be my 8 byte hex-encoded binary content. Real content is much bigger c CLOB := 'cafebabe12345678'; b BLOB; BEGIN -- Need the implementation of this function b := hex_to_blob(c); END; / What's the easiest way to do that in Oracle, using PL/SQL? 回答1: The desired function could look like this: CREATE OR REPLACE FUNCTION hex_to

Write a table (of doubles) to binary file IO C++

旧巷老猫 提交于 2019-12-12 17:23:07
问题 I need to write a matrix with four columns ("g_Grid.r", "g_Grid.t", "g_Grid.b", "g_Grid.ph") Normally, I write to file using file stream: ofstream fout; fout.open("GRID.dat"); for (int m=0;m<N_PH;++m) { for (int k=0;k<N_B;++k) { for (int j=0;j<N_T;++j) { for (int i=0;i<N_R;++i) { fout << setprecision(32) << g_Grid.r[i]<<" "<<g_Grid.t[j]<<" "<<g_Grid.b[k]<<" "<<g_Grid.ph[m]<< endl; } } } } fout.close(); It works fine, but now I'm dealing very large (long) matrix and it takes ages to write the

R - generate all possible pairwise combinations of binary vectors

╄→гoц情女王★ 提交于 2019-12-12 15:11:52
问题 I am looking for a smart way to generate all pairwise combinations of two vectors of length n, where only one value is not zero. For now I am doing something quite desperate with loops through each combination with: n <- 3; z <- rep(0,n); m <- apply(combn(1:n,1),2,function(k) {z[k]=1;z}) but there must be a better way without loops? This is what I'm after for example for n=3: [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [1,] 1 0 0 [2,] 0 0 1 [1,] 0 1 0 [2,] 1 0 0 [1,] 0 1 0 [2,] 0 0 1 [1,] 0 0 1 [2,]

How do you read binary data in C# .NET and then convert it to a string?

。_饼干妹妹 提交于 2019-12-12 12:27:22
问题 As opposed to using StreamReader/Filestream I want to read binary data from files and show that data (formatted) in a textbox. 回答1: There are different cases when one need to read binary file, since it is unclear what you really trying to achieve here are some: read random file and display as series of hex values (similar to binary file view in Visual Studio or any other binary file viewer). Berfectly covered by Jeff M's answer. Reading and writing your own objects using binary serialization.

Java convert bytes to binary safe string

梦想与她 提交于 2019-12-12 11:51:35
问题 I have some data in bytes, and I want to put them into Redis, but Redis only accepts binary safe string, and my data has some binary non-safe bytes. So how can I convert these bytes into binary safe string so that I can save them to Redis? Base64 works for me, but it makes data larger, any better idea? UPDATE: I want to serialize my protobuf object to Redis, and the serialized data has '\x00', so when I read the data from Redis, I can not deserialize the data to object. Then I tried base64,

Accessing bitfields while reading/writing binary data structures

…衆ロ難τιáo~ 提交于 2019-12-12 10:31:43
问题 I'm writing a parser for a binary format. This binary format involves different tables which are again in binary format containing varying field sizes usually (somewhere between 50 - 100 of them). Most of these structures will have bitfields and will look something like these when represented in C: struct myHeader { unsigned char fieldA : 3 unsigned char fieldB : 2; unsigned char fieldC : 3; unsigned short fieldD : 14; unsigned char fieldE : 4 } I came across the struct module but realized

General purpose utility or library for compiling/decompiling binary data files?

穿精又带淫゛_ 提交于 2019-12-12 09:56:51
问题 I have various binary file formats which I need to dump to some kind of text format, edit and then recompile (possibly to a slightly different version of the binary format). Of course I could write a bunch of utility code in C/C++ to do this kind of thing, and maybe leverage a library for the text side of things (XML or JSON or whatever), but this is a task pattern that keeps cropping up in my work and it seems to me that there probably ought to exist already some kind of general purpose tool