binary

Binary Numbers. Error When Checking to be sure binary input is binary...

I'm writing a simple loop to make sure my input is a valid binary. Ex: I want to throw an error when any number higher than one is user input. I know I need to check against the ASCII numbers. What is going on here? I should not be getting an error when I input binary. Any thoughts? for (int i=0;i<size;i++) { printf("%i is string su...

gcc compiled binaries give "cannot execute binary file"

Hi- I compile this program: #include <stdio.h> int main() { printf("Hello World!"); return 0; } With this command: gcc -c "hello.c" -o hello And when I try to execute hello, I get bash: ./hello: Permission denied Because the permissions are -rw-r--r-- 1 nathan nathan 856 2010-09-17 23:49 hello For some reaso...

C# Replace HEX in binary file

I have a binary file, where are a few values what should be changed. To be more exact, at two part of the file, in the beginning, there are two HEX values 66 73 69 6D 35 2E 36 39 what should be changed to 4D 53 57 49 4E 34 2E 31 How could I do this async, and as fast as possible? I've got to the point where I read the whole file in...

Uploading a binary string in WebKit/Chrome using XHR (equivalent to Firefox's sendAsBinary)

I'm working on a webapp that uses several cutting-edge WebKit features. It essentially does this: reads a local file with the FileReader, unzips each file into a string using a JavaScript unzip library, and POSTs each file using XMLHttpRequest. This works great for text files, but unfortunately it corrupts binary files (in this case, ima...

How to convert base64 string to binary array using php.

Hi, I have base 64 encoded string that looks something like this. cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg= I have tried base64_decode and output is. råkq‹å©ŒÞÜæ|c›R©6Ó™œªë´Áäw¸lø I think I may be doing something wrong. I appreciate any help to convert base64 string to binary array. Thanks ...

Failed to read blob data from sqlite

i store blob data with php like this $this->_db->exec"CREATE TABLE media (url TEXT, content BLOB)"); $fp = fopen($encoded['path'], 'rb'); $sql = "INSERT INTO media (url, content) VALUES (?, ?)"; $stmt = $this->_db->prepare($sql); $stmt->bindValue(1, $encoded['url'], PDO::PARAM_STR); $stmt->bindValue(2, $fp, PDO::PARAM_LOB); $stmt->exec...

packing and unpacking variable length array/string using the struct module in python

Hi, I am trying to get a grip around the packing and unpacking of binary data in Python 3. Its actually not that hard to understand, except one problem: what if I have a variable length textstring and want to pack and unpack this in the most elegant manner? As far as I can tell from the manual I can only unpack fixed size strings dire...

Converter and compresser between ASCII and Binary

Hi I am trying to make a very easy converter/compressor; the program should take a file with 4 different types of ASCII characters and writ it out as binary to a file. The program should also read the binary file and convert it to ASCII and print it out on the screen. Under is my code, I can’t really get the char/cstring. What types of ...

C Homework, Print out the binary value of an integer

#include <stdio.h> #include <stdlib.h> // Print out the binary value of an integer void binval (int num); int get_number(); main () { int num; num = get_number(); printf("Num = %d\n",num); binval(num); } void binval (int num) { int val = 0; int test; if (!num) { printf("\n"); return; } test = num & 0x...

Writing cross-platform, stand-alone, binary CGI application?

I notice that small, static, brochure sites would often benefit from adding forms to let users (un)subscribe to an event or mailing list but this means installing some application in the web server referenced in the "action" attribute in HTML forms. To make it easier to install + prevent users from sharing this program, ideally, I'd lik...

How to denote different numeral systems while typing?

Hello, I know that this isn't exactly a programming question, but it's related to the subject for me. How do you denote different numeral systems in just text? (By text I mean able to type at a proper speed and not copy-pasting it from another program.) For example if i have a number in base 2 how do I type it so others can understand th...

django store image in database

Does anyone know if there's an out-of-the box way of storing images directly in the database vs. using ImageField model type that simply uploads it to the MEDIA_ROOT. And if there is, how does one serve those images then? Cheers ...

Strategies for checking ISNULL on varbinary fields?

In the past I've noted terrible performance when querying a varbinary(max) column. Understandable, but it also seems to happen when checking if it's null or not, and I was hoping the engine would instead take some shortcuts. select top 100 * from Files where Content is null I would suspect that it's slow because it's Needing to pul...

addition of "binary" numbers

What is the result of adding the binary numbers 01000001 and 11111111 on an 8 bit machine? ...

How do use a Crash Report from Apple in xCode ?

Hi all, I have received a Crash Report from Apple (joy). I understand I can symbolize this report in order to see what is crashing in my code. I understand I need the dSYM and build binary to do this. My question is what are the exact steps I need to follow in xCode to do this ? I have the build folder I submitted via iTunes connect st...

Howto convert decimal (xx.xx) to binary

This isn't necessarily a programming question but i'm sure you folks know how to do it. How would i convert floating point numbers into binary. The number i am looking at is 27.625. 27 would be 11011, but what do i do with the .625? ...

How do you call this binary data type, and how to handle it in C#?

Let's say we have a binary file that contains 2 bytes that form an integer, in reverse. So for example, the bytes show like this: (hexadecimal) EB 03 00 00 Which should be interpreted as this: 00 00 03 EB Which C# should be able to input as decimal 1003. Is this possible if you have the EB and 03 bytes already in memory in 2 diffe...

Find the successor in a BST without using parent pointer

The successor of an element in a BST is the element's successor in the sorted order determined by the inorder traversal. Finding the successor when each node has a pointer to its parent node is presented in CLRS's algorithm textbook. (Intro to algorithm by MIT press). Now I am thinking another question, can we find the successor without ...

Howto remove unused objects from a git repsitory?

I accidentally added, committed and pushed a huge binary file with my very latest commit to a Git repository. How can I make Git remove the object(s) that was/were created for that commit so my .git directory shrinks to a sane size again? Edit: Thanks for your answers; I tried several solutions. None worked. For example the one from Gi...

Binary representation of a .NET Decimal

Hey all, quick question: How does a .NET decimal type get represented in binary in memory? We all know how floating-point numbers are stored and the thusly the reasons for the inaccuracy thereof, but I can't find any information about decimal except the following: Apparently more accurate than floating-point numbers Takes 128 bits of...