binary

Is there any benefit to my rather quirky character sizing convention?

I love things that are a power of 2. I celebrated my 32nd birthday knowing it was the last time in 32 years I'd be able to claim that my age was a power of 2. I'm obsessed. It's like being some Z-list Batman villain, except without the colourful adventures and a face full of batarangs. I ensure that all my enum values are powers of 2...

Python: Fastest way to iterate this through a large file

Right, I'm iterating through a large binary file I need to minimise the time of this loop: def NB2(self, ID_LEN): r1=np.fromfile(ReadFile.fid,dTypes.NB_HDR,1) num_receivers=r1[0][0] num_channels=r1[0][1] num_samples=r1[0][5] blockReturn = np.zeros((num_samples,num_receivers,num_channels)) for rec in range(0,nu...

reading binary datafile and writing into decimal no file

exp data is generated by my mc scaler card as a binary file with first 511 bytes as header and then 24 bit data followed by four bit roi data. i am not a expert in programming. i do understand a little. I would like to convert this file into a file (without header) decimal nos with first col as channel no (1 to 8191) then the data (24 bi...

JS function for writing out a word, binary counter style

How can I create a loop to output any given word like this: ...if the word is 'abcd' a--- -b-- ab-- --c- a-c- -bc- abc- ---d a--d -b-d ab-d --cd a-cd -bcd abcd in other words, letters appear in binary counter order 1000 0100 1100 0010 1010 etc. Thanks ...

Does exist any utility to know the size of a compiled function in an executable?

I want a report showing me the size of diferent symbols(compiled) in the executable. Something like .map files in Delphi, but generic if possible. nm from binutils, shows start address(?), maybe could i use that information? (I'm using object pascal + freepascal compiler) ...

How can I return binary image data from an abortable AJAX request and set the result to the src of an HTML/DOM image?

I'm writing a web application that involves a continuous cycle of creating (and removing) a fair number of images on a webpage. Each image is dynamically generated by the server. var img = document.createElement("img"); img.src = "http://mydomain.com/myImageServer?param=blah"; In certain cases, some of these images outlive their usefu...

How to convert a string or integer to binary in Ruby?

Let's say I need to make integers 0..9 and math operators + - * / binary strings. So 0 = 0000, 1 = 0001, etc.. Is there a way to do this with Ruby 1.8.6 without using a library? ...

Why are all the lines returned by `svn blame Foo.cs` blank?

I have a file in my Subversion repository named "Foo.cs". When I run the command svn blame Foo.cs the output looks something like this: 1000 dave 1000 dave 2000 dave 2000 dave 9999 dave 1000 dave 9999 dave The only thing that I can think of is that from revisions 1000-9000, Foo.cs had the "svn:mime-type" property set to "application...

Java to/from C++ socket communication, DataInputStream and eof, binary, encryption

I'm trying to have Java server and C++ clients communicate over TCP under the following conditions: text mode, and binary/encrypted mode. My problem is over the eof indicator for end of stream that DataInputStream's read(byte []) uses to return with -1. If I send binary data, what's to prevent a random byte sequence happening to repres...

creating an executable file without a compiler

I came across an article a long while ago on how to write out a .com file directly without using any external tools. the method was to basically copy con myfile.com and then hit ctrl+alt+number for each instruction. I've lost the url for the guide... Google isn't helping much either. If you have the link, please could you post it. ...

Reading binary data without reinterpret_cast

Just because I've never read binary files before I wrote a program that reads binary STL files. I use ifstreams read member that takes a char* a parameter. To cast my struct to a char* I use a reinterpret_cast. But as far as I remember every book about C++ I read said something like "don't use reinterpret_cast except you have to". What w...

Python: slicing a very large binary file

Say I have a binary file of 12GB and I want to slice 8GB out of the middle of it. I know the position indices I want to cut between. How do I do this? Obviously 12GB won't fit into memory, that's fine, but 8GB won't either... Which I thought was fine, but it appears binary doesn't seem to like it if you do it in chunks! I was appending ...

Questions Regarding the Implementation of a Simple CPU Emulator

Background Information: Ultimately, I would like to write an emulator of a real machine such as the original Nintendo or Gameboy. However, I decided that I need to start somewhere much, much simpler. My computer science advisor/professor offered me the specifications for a very simple imaginary processor that he created to emulate first....

binary vs text protocols

hi, I am wondering what the differences are between binary and text based protocols. I read that binary protocols are more compacts/faster to process. How does that work out? Since you have to send the same amount of data? No? E.g how would the string "hello" differ in size in binary format? thanks ...

Python 2.x - Write binary output to stdout?

Is there any way to write binary output to sys.stdout in Python 2.x? In Python 3.x, you can just use sys.stdout.buffer (or detach stdout, etc...), but I haven't been able to find any solutions for Python 2.5/2.6. EDIT, Solution: From ChristopheD's link, below: import sys if sys.platform == "win32": import os, msvcrt msvcrt.se...

c++ binary read/write problem

I've looked at binary reading and writing objects in c++ but are having some problems. It "works" but in addidion i get a huge output of errors/"info". What i've done is Person p2; std::fstream file; file.open( filename.c_str(), std::ios::in | std::ios::out | std::ios::binary ); file.seekg(0, std::ios::beg ); file.read ( (char*)&p2, s...

Read plain text from binary file with PHP

File 1: asdffdsa File 2: asdfjklfdsaHGUik How do I read these binary files with PHP such that I can populate an array with the plaintext like: $file1_output = ["asdf", "fdsa"]; $file2_output = ["asdfjkl", "fdsaHGUik"]; ...

How to cut a mpz_t into two parts using GMP lib on C?

Using GMP on c, I have a big integer "mpz_t n" in decimal form, how can I cut it into 2 parts? In fact, these 2 parts should have the same length in binary. For example, maybe I can convert the n to a binary of 112bits, then I want to cut it into 2 56bits parts. Thanks ...

Prolog homework: how to parse a list of 'bits' representing a numeric value into a decimal representation?

Okay, so I have another question on a prolog homework problem I am struggling with. The problem goes as follows: Write a Prolog program that will take a list representing the bits of a binary number, and return the decimal value of the integer that the list represents. Example: valueof([1,1,0,1],X). X = 13 So here's what I hav...

C# divide two binary numbers

Is it possible in C# to divide two binary numbers. All I am trying to do is: // get int value into binary format, see below int days = 68; string binary = Convert.ToString(days, 2); // but how do you divide the binary numbers? , what format should be used? 01000100 / 000000100 = 4 Little confused any help would be great. ...