unsigned

Convert base64 encoded string to java byte array

I am writing a decryption class (AES/CBC/PKCS7Padding) where the encrypted data is coming from C#. I want to take the following string (which is base64 encoded): usiTyri3/gPJJ0F6Kj9qYL0w/zXiUAEcslUH6/zVIjs= and convert it to a byte array in java to pass into the SecretKeySpec as the key. I know there is the issue of C# having unsigned ...

why is char's sign-ness not defined in C?

The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. And indeed gcc define that accord...

C# multi-threaded unsigned increment

I want to increment an unsigned integer from multiple threads. I know about Interlocked.Increment, but it does not handle unsigned integers. I could use lock(), but I would rather not if possible for performance reasons. Is it thread safe just to increment it in the normal way? It would not matter if the occasional increment got lost,...

Compiler warnings

Suppose I have this (C++ or maybe C) code: vector<int> my_vector; for (int i = 0; i < my_vector.size(); i++) { my_vector[i] = 0; } I don't care if it's done right. The important part is in the for-loop declaration. The compiler gives a signed/unsigned mismatch for this, since size() returns an unsigned int, not a signed one. How i...

Windows Mobile unsign app security prompt

I have a windows mobile app (mymobiler) that i am trying to install and run in my windows mobile phone. As soon as it gets installed it prompts the user with Yes/No option whether to let the program run in the device. Is there anyway to by pass this? I understand this is just one time , but i just want to know whether if i can avoid th...

How to cast a 32-bit integer from unsigned to signed in MySQL or PHP?

Hello, I have a string in PHP (came from some data source), which represents a formatted unsigned 32-bit integer. I need to store it into a MySQL database as a signed 32-bit integer, so that later I can retrieve it from PHP and use it as a (possibly negative) signed integer constant (since PHP doesn't have unsigned integers). So, what ...

what is the unsigned datatype?

I've seen this unsigned "typeless" type used a couple of times, but never seen an explanation for it. I suppose there's a corresponding signed type. Here's an example: static unsigned long next = 1; /* RAND_MAX assumed to be 32767 */ int myrand(void) { next = next * 1103515245 + 12345; return((unsigned)(next/65536) % 32768); } v...

In Silverlight, can one define min/max values for a DependencyProperty?

For example, I have a dependency property that changes the ScaleTransform of a Canvas, but if it ever goes below zero it throws an error. Sure, I could just force it to zero in the code if that ever happens, but I'd rather use a better method like using a udouble (unsigned double), which doesn't exist in Silverlight or even setting the m...

Defined behavior of cast from unsigned char * to char * in Objective-C

I understand the difference between unsigned char * and char * types. I also understand how to use reinterpret_cast to cast an unsigned char * to a char * in C++. I'm using sqlite3 in Objective-C and am trying to get an NSString from a call to sqlite3_column_text(...); To do this, I'm basically doing: char *cParam = (char *)sqlite...

What should happen to the negation of a size_t (i.e. `-sizeof(struct foo)`))?

I'm dealing with some code at work that includes an expression of the form -(sizeof(struct foo)) i.e. the negation of a size_t, and I'm unclear on what the C and C++ standards require of compilers when they see this. Specifically, from looking around here and elsewhere, sizeof returns an unsigned integral value of type size_t. I can'...

Downloading a file over https over java

Hi, Here is a code that I copied from the web /** * A simple example that uses HttpClient to perform a GET using Basic * Authentication. Can be run standalone without parameters. * * You need to have JSSE on your classpath for JDK prior to 1.4 * * @author Michael Becke */ public class BasicAuthenticationExample { /** ...

Ruby - read bytes from a file, convert to integer

Hey, I'm trying to read unsigned integers from a file (stored as consecutive byte) and convert them to Integers. I've tried this: file = File.new(filename,"r") num = file.read(2).unpack("S") #read an unsigned short puts num #value will be less than expected What am I doing wrong here? Cheers, Pete ...

How to declare 8-bit unsigned integer in ruby?

In c++ you can do: uint8 foo_bar How would we do the same thing in ruby? Any alternatives? This post seems close to it maybe someone can explain? ...

How to convert char * to unsigned int in C programming in win32

Hi I am trying to convert char *str = "10.20.30.40" ; in to unsigned int . can u pls tell me any method is there or any sample code . pls share me. ...

C# Convert.ToInt16(String) C Equivalent

What is the C equivalent of Convert.ToInt16(String) method of C#? In my case my string is a char array. Thanks ...

How to get the signed integer value of a long in python?

If lv stores a long value, and the machine is 32 bits, the following code: iv = int(lv & 0xffffffff) results an iv of type long, instead of the machine's int. How can I get the (signed) int value in this case? ...

storing a value from an unsigned interger (2bytes long) to an unsigned char variable using bitwise operators?

How do I put the value of 0x04 in register 4 if the instruction was 1rxy? 1RXY-Load register R with the value at memory address XY #include <stdio.h> unsigned char r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,ra,rb,rc,rd,re,rf; void reg_check(unsigned char reg); void rxy1(unsigned char reg, unsigned char val); int main(){ unsigned char memloc1=...

How do you get an unsigned long out of a string?

What's the safest and best way to retrieve an unsigned long from a string in C++? I know of a number of possible methods. First, converting a signed long taken from atol. char *myStr; // Initalized to some value somehow. unsigned long n = ((unsigned)atol(myStr)); The obvious problem with this is, what happens when the value stored i...

PHP's unsigned integer on 32 bit and 64 bit platform

Here is the code: echo sprintf('%u',-123); And this is the output on 32 bit platform: 4294967173 but on 64 bit: 18446744073709551493 How to make it the same ?Say,the int(10) unsigned ...

Java: Unsigned numbers

Hello, Is there a way in Java to use Unsigned numbers like in (My)SQL? For example: I want to use an 8-bit variable (byte) with a range like: 0 -> 256; instead of -128 -> 127. ...