I have a file, its contents are identical. It is passed into gzip and only the compressed form is stored. I'd like to be able to generate the zip again, and only update my copy should they differ. As it stands diffing tools (diff, xdelta, subversion) see the files as having changed.
Premise, I'm storing a mysqldump of an important data...
I am learning C and am trying to write a program that will take 2 value from a user and will check if these strings are binary values (composed of the characters 1 or 0 is how I approached it) before attempting to, according to user selection:
Add the two values,
Subtract input 2 from input 1, or
Multiply the two values.
I can implem...
In a binary search, we have two comparisons one for greater than and other for less
than, otherwise its the mid value. How would you optimize so that we need to check only once?
bool binSearch(int array[], int key, int left, int right)
{
mid = left + (right-left)/2;
if (key < array[mid])
return binSearch(array, key, lef...
We're having a spirited discussion about this at my workplace. We're talking about user uploaded images for a bunch of products, not images needed to display the basic site. I say "no way" but I'm curious what others think.
Update: Just to clarify. These are customer supplied images for products that they are entering/modifying.
...
I need to find an algorithm for generating every possible permutation of a binary tree, and need to do so without using lists (this is because the tree itself carries semantics and restraints that cannot be translated into lists). I've found an algorithm that works for trees with the height of three or less, but whenever I get to greater...
Following my earlier question. Is there a way to write a string in a compressed/bit version using C++ native idiom. I am thinking something like Perl's native pack and unpack.
...
I need a utility to diff two binary files. The files are large (6-50GB)
Beyond Compare is my favorite diff tool, and I own it, but it cannot handle binary files over what can fit in the process's address space.
HexDiff 3.0 seemed interesting, except the trial version doesn't do diff's. *rolls eyes*
The tool should be free, since I'm ...
hi,
I've a native binary dependency for my c# solution which comes in Debug and Release variants, and I'm trying to figure out how to best organize this such that
(1) It ends up in the build output, and is found when running unit tests
(2) It lives under the checkout directory in source control
(3) The correct variant (debug/release)...
Is this the best way to convert a Python number to a hex string?
number = 123456789
hex(number)[2:-1].decode('hex')
Sometimes it doesn't work and complains about Odd-length string when you do 1234567890.
Clarification:
I am going from int to hex.
Also, I need it to be escaped.
IE:
1234567890 -> '\x49\x96\x02\xd2' not '499602D2'
...
I'm using a well known template to allow binary constants
template< unsigned long long N >
struct binary
{
enum { value = (N % 10) + 2 * binary< N / 10 > :: value } ;
};
template<>
struct binary< 0 >
{
enum { value = 0 } ;
};
So you can do something like binary<101011011>::value. Unfortunately this has a limit of 20 digits for a ...
Still learning C and I was wondering:
Given a number, is it possible to do something like the following?
char a = 5;
printf("binary representation of a = %b",a);
> 101
Or would i have to write my own method to do the transformation to binary?
...
I am trying to return a binary from the DB using linq for display in the browser. The method below using ado.net works but I am trying to ypgrade to linq but the linq version returned the error.
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Dim imageId As String = context.Request.QueryString("id")
Dim r...
I have a (void*) buffer that I need to convert to std::vector<unsigned char> before I can pass it on. Unfortunately, my C++ casting skills a little weak. Any suggestions?
...
A while back (freshman year of high school) I asked a really good C++ programmer who was a junior to make a simple application to convert a string to binary. He gave me the following code sample:
void ToBinary(char* str)
{
char* tempstr;
int k = 0;
tempstr = new char[90];
while (str[k] != '\0')
{
itoa((int)str...
What is the best way to search a large binary file for a certain substring in C#?
To provide some specifics, I'm trying to extract the DWARF information from an executable, so I only care about certain parts of the binary file (namely the sections starting with the strings .debug_info, .debug_abbrev, etc.)
I don't see anything obvious ...
I want to define my own datatype that can hold a single one of six possible values in order to learn more about memory management in c++. In numbers, I want to be able to hold 0 through 5. Binary, It would suffice with three bits (101=5), although some (6 and 7) wont be used. The datatype should also consume as little memory as possible....
It's been a while from those school years. Got a job as IT specialist at a hospital. Trying to move to do some actual programming now. I'm working on binary trees now, and I was wondering what would be the best way to determine if the tree is height-balanced.
I was thinking of something along this:
public boolean isBalanced(Node r...
I have a file containing 800 lines like:
id binary-coded-info
---------------------------
4657 001001101
4789 110111111
etc.
where each 0 or 1 stands for the presence of some feature.
I want to read this file and do several bitwise logical operations on the
binary-coded-info (the operations depend on user input
and on in...
Does anyone know if/how I can convert a binary formatted Mac OS X plist file to a plain XML string in C#?
I know there are some plist editors for Windows available that says they support binary formatted plist files, but I need to do this inline in my own application.
...
I need to convert 0.5 in base 10 to base 2 (0.1).
I have tried using
Double.doubleToRawLongBits(0.5)
and it returns 4602678819172646912 which I guess is in hex, but it does not make sense to me.
...