binary

Binary socket and policy file in Flex

Hi, I'm trying to evaluate whether Flex can access binary sockets. Seems that there's a class calles Socket (flex.net package). The requirement is that Flex will connect to a server serving binary data. It will then subscribe to data and receive the feed which it will interpret and display as a chart. I've never worked with Flex, my expe...

Monodevelop - Ubuntu - exe file as output?

Hi everyone, OK I'm creating an app in MonoDevelop for Ubuntu Linux, but the compiled file is always a windows exe, I've set it to compile as a Linux Binary but I'm confused, can anyone shed any light on how to get a proper Linux way of opening the program? Thanks ...

Binary to Ascii and back again

I'm trying to interface with a hardware device via the serial port. When I use software like Portmon to see the messages they look like this: 42 21 21 21 21 41 45 21 26 21 29 21 26 59 5F 41 30 21 2B 21 27 42 21 21 21 21 41 47 21 27 21 28 21 27 59 5D 41 32 21 2A 21 28 When I run them thru a hex to ascii converter the commands don't m...

InternetReadFile() corrupting downloads in C

I'm able to download text documents (.html, .txt, etc) but I can't download images or exe's. I'm pretty sure that this is because I'm using a char, and those files are binary. I know that in C# I would use a byte. But what data-type would I use in this case? char buffer[1]; DWORD dwRead; FILE * pFile; pFile = fopen(file,...

adding virtual function to the end of the class declaration avoids binary incompatibility?

Could someone explain to me why adding a virtual function to the end of a class declaration avoids binary incompatibility? If I have: class A { public: virtual ~A(); virtual void someFuncA() = 0; virtual void someFuncB() = 0; virtual void other1() = 0; private: int someVal; }; And later modify this class decl...

Trying to figure out how to check a checksum

I'm trying to figure out how to check a checksum. My message looks like this: 38 0A 01 12 78 96 FE 00 F0 FB D0 FE F6 F6 being the checksum. I convert the preceding 12 sets in to binary and then add them together. Then attempt a bitwise operation to apply the 2s complement. I get a value of -1562, but I can't convert it back to hex to ...

Boost Binary Endian parser not working?

I am studying how to use boost spirit Qi binary endian parser. I write a small test parser program according to here and basics examples, but it doesn't work proper. It gave me the msg:"Error:no match". Here is my code. #include "boost/spirit/include/qi.hpp" #include "boost/spirit/include/phoenix_core.hpp" #include "boo...

What is the algorithm of Skeleton

Hey, This function bwmorph(Img,'skel',Inf) return the skeleton of a binary image. What I'm looking for is the algorithm used by this function to do it manualy ? ...

Binary image in Matlab

How can I know if an image read with imread is binary in MATLAB I did this : Img = imread(IMGsrc); T = Img== 1 | Img == 0; If min(min(T)) == ?????? imshow(T); end ????? = ?????? ...

How to convert an int to a binary number to a string in C++

I have an int that I want to first convert to a binary number. Then I want to store that binary number in a string. How can this be done? ...

Get length of bits used in int

If you have the binary number 10110 how can I get it to return 11111? e.g a new binary number that sets all bits to 1 after the first 1, there are some likewise examples listed below: 101 should return 111 (3 bit length) 011 should return 11 (2 bit length) 11100 should be return 11111 (5 bit length) 101010101 should return 111111111 (9 ...

Getting the Leftmost Bit

I have a 5 bit integer that I'm working with. Is there a native function in Objective-C that will let me know which bit is the leftmost? i.e. I have 01001, it would return 8 or the position. Thanks ...

Packing a file into an ELF executable

Hello, I'm currently looking for a way to add data to an already compiled ELF executable, i.e. embedding a file into the executable without recompiling it. I could easily do that by using cat myexe mydata > myexe_with_mydata, but I couldn't access the data from the executable because I don't know the size of the original executable. D...

how to init binary buffer in python

so, I read from DB binary field i.e. 'field1' to var Buf1, and then do something like: unpack_from('I', Buf1, 0) so, all is ok. but question is how can I ini Buf1 without going to DB? I can get value from DB manually and init my var statically, but how? in DB field 'field1' I see something like '0x7B0500000100000064000000B80100006'. ...

How many posibilities on a binary ?

in hexadecimal "10 10 10 10" system you have 0-255 posibilities right? in total 256 different posibilities as there are 8 1s and 0s. how many different posibilities would i get? if i had 10 digits. instead of 8? or how would i calculate that in php ? ...

parse content away from structure in a binary file

Using C#, I need to read a packed binary file created using FORTRAN. The file is stored in an "Unformatted Sequential" format as described here (about half-way down the page in the "Unformatted Sequential Files" section): http://www.tacc.utexas.edu/services/userguides/intel8/fc/f_ug1/pggfmsp.htm As you can see from the URL, the file i...

Detecting if a file is binary or plain text?

How can I detect if a file is binary or a plain text? Basically my .NET app is processing batch files and extracting data however I don't want to process binary files. As a solution I'm thinking about analysing first X bytes of the file and if there are more unprintable characters than printable characters it should be binary. Is thi...

Is it possible to compare a binary file in c#?

I want to replace a binary file if the contents are different. So I need to be able to compare the binary file (without having to deserialize it). Is this possible? I used binary formatter to save the file. ...

Doubling binary digits

How to double a number of binary digits in an integer? For example, if bin(x)="1001" then bin(y) must be "11000011". Is there any smart and fast algorithm ? UPDATE: Here is an elegant solution: ''.join([''.join(i) for i in zip(X,X)]) where X is bin(int_x)[2:] However, I am interested in a more faster way and for the integers of any...

Ajax for binary data with jQuery?

I have a response which may return text/html or application/octet-stream. If I receive html, I'd like to replace part of the page with the returned response data, and if I receive binary data (a file download), I would like to display a message and send the data to the browser so that the user can download the file. Is there any way to d...