I'm parsing a binary file in javascript that is storing two pieces of information per byte, one per nibble. The values are, of course, 0-16 and 0-16.
In all other parts of the file format, each byte represents one piece of information, so I have been using the following to successfully get the number values I need:
var num = str.charCo...
I have one table that has 2 fields one(container_id) for numeric type and another for byte type(coDearntainer_objects) .
I would like to read the byte field(container_objects) as a string for corresponding (container_id)
field.
How could I do this? I am using Postgresql Db
Table Structure:
CREATE TABLE container
(
ct_id numeric,
co...
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...
How do you get a byte array out of a string in C#? I would like to pass a string to this method.
...
i would like to send a stream of bytes to a serial port using the command line. is this possible? my serial port is at /dev/cu.usbserial-A700dYoR on my Mac. for example, if i wanted to send the integer 50 or the string "data" to that serial port, how can i do that?
my knowledge of UNIX is very limited.
...
How to I use logical operators to determine if a bit is set, or is bit-shifting the only way?
I found this question that uses bit shifting, but I would think I can just AND out my value.
For some context, I'm reading a value from Active Directory and trying to determine if it a Schema Base Object. I think my problem is a syntax issue...
This is a somewhat of a follow up to this posting (http://stackoverflow.com/questions/2718712/how-to-convert-byte-value-into-int-in-objective-c) but with a different question so I felt I should ask in a separate thread.
I am at the point where I have four consecutive bytes in memory that I have read in from a file. I'd like to store ...
I need to access SecureRandom Java Object from Javascript. My ultimate goal is to grab 4 bytes from PRNG and convert it to Javascript integer variable. According to http://download.oracle.com/javase/1.4.2/docs/api/java/security/SecureRandom.html, the following two lines of Java code are supposed to do grab 4 random bytes:
byte bytes[] ...
Assuming that a memory address occupies 4 bytes and a char occupies 1 byte:
char** t;
t = malloc(5 * sizeof(char*));
int i;
for (i = 0; i < 5; i++)
t[i] = malloc(sizeof(char) * (i+1));
...
So at work yesterday, I had to write an application to count the pages in an AFP file. So I dusted off my MO:DCA spec PDF and found the structured field BPG (Begin Page) and its 3-byte identifier. The app needs to run on an AIX box, so I decided to write it in Java.
For maximum efficiency, I decided that I would read the first 6 bytes ...
I need to create a Python string consisting of non-ascii bytes to be used as a command buffer in a C module.
I can do that if I write the string by hand:
mybuffer = "\x00\x00\x10"
But I cannot figure out how to create the string on the fly if I have a set of integers which will become the bytes in the string. Concatenating an integer ...
I was working on this for a while and did not find anything about this on here, so I thought I would post my solution for criticism/usefulness.
import java.lang.*;
public class Concat
{
public static void main(String[] args)
{
byte[] buf = new byte[256];
int lastGoodChar=0;
//fill it up for example o...
I have an odd scenario (see this answer for more details), where I need to add two bytes of data together. Obviously this is not normal adding. Here is the scenario:
I am trying to get a coordinate out of a control. When the control is less that 256 in width then the x coordinate takes one byte, otherwise it takes two bites.
So, I n...
Hi guys,
I'm trying to solve the following problem. I want to create a set of directories with files in them , but in memory using C# , using strings / byte arrays, and I am trying to figure out what's the format and byte sequence for all of this. i mean something like
<magic sequence for top directory header> <magic sequence for file ...
I'm saving a BitmapImage to a byte[] for saving in a DB. I'm pretty sure the data is being saved and retrieved accurately so it's not an issue there.
On my byte[] to BitmapImage conversion I keep getting an exception of "System.NotSupportedException: No imaging component suitable to complete this operation was found."
Can anyone see w...
Often I have some compile-time constant number that is also the upper limit of possible values assumed by the variables. And thus I'm interested in choosing the smallest type that can accomodate those values. For example I may know that variables will fit into <-30 000, 30 000> range, so when looking for a suitable type I would start wit...
I'm working on a homework assignment for my C++ class. The question I am working on reads as follows:
Write a function that takes an unsigned short int (2 bytes) and swaps the bytes. For example, if the x = 258 ( 00000001 00000010 ) after the swap, x will be 513 ( 00000010 00000001 ).
Here is my code so far:
#include <iostream>
u...
How do I convert an int to two bytes in C#?
...
When declaring a byte array, what is the difference between the following? Is there one, or are these just two different ways of going about the same thing?
Dim var1 As Byte()
Dim var2() As Byte
...
Hello Everyone,
I am connecting to a server which sends updates about financial information. The code I post below will work correctly for a few minutes then usually blows up when it tries to do an EndRead (where I have noted), because there was 0 bytes at that moment to be read. Obviously in the financial world some things can stay t...