binary

Reading a .dat file as "rb" read binary

I have a folder \folder\ above the webroot that contains .php, .inc, .dat files the .php can access the .inc no problem but when the .inc tries to access the .dat using fopen('mydat.dat', "rb"); it gives an error that it can't find mydat.dat inside \folder\myinc.inc Of course it can't find it since .inc is a file not a folder. Why i...

importing C written binary files into Matlab

Hi, I've read the post "Read and write from/to a binary file in Matlab" but I still have doubts. I have a binary file of long double values created with fwrite in C and in Matlab I'm using fid = fopen('vz3.dat', 'r') mydata = fread(fid, 'double') where vz3.dat is my file. But I'm getting garbage values in Matlab. According to [ci...

Working with bytes and binary data in Python

Four consecutive bytes in a byte string together specify some value. However, only 7 bits in each byte are used; the most significant bit is always zero and therefore its ignored (that makes 28 bits altogether). So... b"\x00\x00\x02\x01" would be 000 0000 000 0000 000 0010 000 0001. Or, for the sake of legibility, 10 000 0001. That's...

Getting a specific bit value in a byte string

There is a byte at a specific index in a byte string which represents eight flags; one flag per bit in the byte. If a flag is set, its corresponding bit is 1, otherwise its 0. For example, if I've got b'\x21' the flags would be 0001 0101 # Three flags are set at indexes 0, 2 and 4 # and the others are not set What w...

Write to a binary file?

Here is data structure w/ variables: struct Part_record { char id_no[3]; int qoh; string desc; double price: }; --- (Using "cin" to input data) --- Part_record null_part = {" ", 0," ",0.0}; --- --- file.seekg( -(long)sizeof(Part_record), ios::cur); file.write( ( char *)&part, sizeof(Part_record) ...

C# TCP socket and binary data

Hi @All How to send binary data (01110110 for exemple) with C# throught a TCP (using SSL) socket ? I'm using : SslStream.Write() and h[0] = (byte)Convert.ToByte("01110110"); isn't working Thanks. ...

two's complement, why the name "two"

i know unsigned,two's complement, ones' complement and sign magnitude, and the difference between these, but what i'm curious about is: why it's called two's(or ones') complement, so is there a more generalize N's complement? in which way did these genius deduce such a natural way to represent negative numbers? ...

binary sed replacement

I was attempting to do a sed replacement in a binary file however I am beginning to believe that is not possible. Essentially what I wanted to do was similar to the following: sed -bi "s/\(\xFF\xD8[[:xdigit:]]\{1,\}\xFF\xD9\)/\1/" file.jpg The logic I wish to achieve is: scan through a binary file until the hex code FFD8, continue re...

Can I use a binary literal in C or C++?

I need to work with a binary number. I tried writing: const x = 00010000 ; But it didn't work. I know that I can use an hexadecimal number that has the same value as 00010000 but I want to know if there is a type in C++ for binary numbers & if there isn't, is there another solution for my problem? ...

why IEEE floating point number calculate exponent using a biased form?

let's say, for the float type in c, according to the IEEE floating point specification, there are 8-bit used for the fraction filed, and it is calculated as first taken these 8-bit and translated it into an unsigned number, and then minus the BIASE, which is 2^7 - 1 = 127, and the result is an exponent ranges from -127 to 128, inclusive....

Project with multiple binaries in Eclipse CDT

I think it is quite normal to have more than one binary in a project. However, with Eclipse CDT I don't know how to set up the IDE to get things done. I know I can create several projects - one per binary. And I know I can set the dependencies per project. However, I cannot regard them as one project in Eclipse. If I'd like to share the...

C++ exceptions binary compatibility

hi. my project uses 2 different C++ compilers, g++ and nvcc (cuda compiler). I have noticed exception thrown from nvcc object files are not caught in g++ object files. are C++ exceptions supposed to be binary compatible in the same machine? what can cause such behavior? try { kernel_= new cuda:: Kernel(); } catch (...) { kernel_= NULL...

WIX: Using a temporary file during install

Hello! I am writing a WIX installer and I have a following requirement: During installation, I need to pass an absolute path to a file (lets call it A) included in my installer to a COM component, which already exists on the hard drive and is a part of another program. I have already written an appropriate Custom Action which expects a ...

Embedding binary blobs using gcc mingw

I am trying to embed binary blobs into an exe file. I am using mingw gcc. I make the object file like this: ld -r -b binary -o binary.o input.txt I then look objdump output to get the symbols: objdump -x binary.o And it gives symbols named: _binary_input_txt_start _binary_input_txt_end _binary_input_txt_size I then try and acce...

How to get the binary data from a download link

Hi all, I need to get the binary data of a download link. When I run this link in the browser it always starts download manager. Rather I would like to copy that binary and display it on teh browser. How is this possible in any language. Objective c or c# preferred. Thanks ...

Binary to Date (C#) 64 Bit Format

We have a binary file from which we have identified the following dates (as Int64). We now the following facts about the Date/Time format; The 64 bit Date has a resolution to the microsecond The 64 bit Date has a range of 4095 years The Int64 9053167636875050944 (0x7DA34FFFFFFFFFC0) = 9th March 2010 The Int64 9053176432968073152 (0x7DA...

why is this C++ Code not doing his job

i want to create a program that write all the primes in a file ( i know that its a popular algorithm "Sieve of Eratosthenes" but m trying to make it by my self ) i m trying to eliminate all the complications for the bites that still have the value 1 then wrote them in a File #include <iostream> #include <stdlib.h> #include <stdio.h...

Python and C++ Sockets converting packet data

First of all, to clarify my goal: There exist two programs written in C in our laboratory. I am working on a Proxy Server (bidirectional) for them (which will also mainpulate the data). And I want to write that proxy server in Python. It is important to know that I know close to nothing about these two programs, I only know the definitio...

Transferring binary data through a SOAP webservice? C# / .NET

I have a webservice that returns the binary array of an object. Is there an easier way to transfer this with SOAP or does it need to be contained in XML? It's working, but I had to increase the send and receive buffer to a large value. How much is too much? Transferring binary in XML as an array seems really inefficient, but I can't see...

PHP: Simple, Validate if string is hex?

I have no clue how to validate this string. I am simply supplying an IV for an encryption, but can find no "is_hex()" or similar function, I can't wrap my head around it! I read on a comment in the php documentation (user contrib. notes) this: if($iv == dechex(hexdec($iv))) { //True } else { //False } But that doesn't seem to work...