signed

What is the best way to work around the fact that ALL Java bytes are signed?

In Java, there is no such thing as an unsigned byte. Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign. What's a good way to work around this? (Saying don't use Java is not an ...

Downloading Java classes from inside a (signed) applet

If I'm running a signed Java applet, can I download additional classes from remote sources (in the same domain, maybe even the same host) and run them? I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once. Is there a way to do this...

When I calculate a large factorial, why do I get a negative number?

So, simple procedure, calculate a factorial number. Code is as follows. int calcFactorial(int num) { int total = 1; if (num == 0) { return 0; } for (num; num > 0; num--) { total *= num; } return total; } Now, this works fine and dandy (There are certainly quicker and more elegant solutions,...

Signed versus UnSigned Integers

Am I correct to say the difference between a signed and unsigned integer is: UnSigned can hold a larger positive value, and no negative value. Unsigned uses the leading bit, while the signed version uses the left-most-bit to identify if the number is positive or negative. signed integers can hold both positive and negative numbers. A...

Extracting a bit-field from a signed number

Hello, I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ? For positive numbers it is trivially true, and it seems t...

Using ruby to convert unsigned integers stored as signed back to the original value

A C-program is placing what it considers to be 64-bit unsigned integers into a column in a Postgres database that is typed as int8. To Postgres, int8 is always 'signed int8' (no such thing to it as 'unsigned int8'). So the Ruby program I have shows numbers retrieved from Postgres in the upper half of that space as negative. What is the ...

How to load only signed assembly to a new AppDomain?

I'm doing a addin system where the main app loads assemblies Addin1.dll and Addin2.dll on runtime in new AppDomain's. However, in case that Addin1.dll is signed (strong name) with my key and Addin2.dll is not, I want to be able to only load Addin1.dll and reject Addin2.dll. I'm suspecting that it needs to be done by setting some parame...

conversion of unicode string in python

I need to convert unicode strings in Python to other types such as unsigned and signed int 8 bits,unsigned and signed int 16 bits,unsigned and signed int 32 bits,unsigned and signed int 64 bits,double,float,string,unsigned and signed 8 bit,unsigned and signed 16 bit, unsigned and signed 32 bit,unsigned and signed 64 bit. I need help fro...

How to determine the variable type in Python

I want to see the type of a variabe whether it is unsigned 32 bit,signed 16 bit etc. How to view... ...

iPhone - HTTPS connection to Server with Self-Signed Certificate

How would I accept a self-signed server certificate? Using the code below, I can only connect/authenticate after I accept the Server Cert using Safari. (void)secure:(NSString *)username credentials:(NSString *)login { NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:username pass...

Mixed signed assemblies in 1 VS solution?

Hey, currently I am trying to run a project (Noizwaves.Client) which has a dependency (as a project reference) to a signed class library (Noizwaves.Core). Noizwaves.Core has it's assembly version set to 2.0.*. I have both of these projects within the same VS2008 solution file. Noizwaves.Client is set as the default startup project. All ...

Java negative int to hex and back fails

Hello, public class Main3 { public static void main(String[] args) { Integer min = Integer.MIN_VALUE; String minHex = Integer.toHexString(Integer.MIN_VALUE); System.out.println(min + " " + minHex); System.out.println(Integer.parseInt(minHex, 16)); } } Gives -2147483648 80000000 Exception in thread "main"...

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...

signed applet gives AccessControlException: access denied, when calling from javascript

I have an easy self-signed an applet (done with keytool and the jarsigner): public class NetAppletLauncher extends JApplet { private static final long serialVersionUID = 1L; public void init() { exec("notepad c:/hello.txt"); } public void exec(String command) { try { // launch EXE and grab stdin/stdout and stderr Proc...

C++ convert hex string to signed integer

I want to convert a hex string to a 32 bit signed integer in C++. So, for example, I have the hex string "fffefffe". The binary representation of this is 11111111111111101111111111111110. The signed integer representation of this is: -65538. How do I do this conversion in C++? This also needs to work for non-negative numbers. F...

Signed 64 by 32 integer division

Assuming you have a machine instruction udive that does a special case 64 by 32 unsigned division by taking a (32bit dividend << 32) / 32bit divisor, we can do a full 64 by 32 division using the following: // assume: a / b guaranteed not to overflow a = 64bit dividend, a.h & a.l are hi & lo 32bits respectively b = 32bit divisor q1 = ud...

In C Left shift (char) 0xFF by 8 and cast it to int

Hello People On left shift of (char) 0xff by 8 and casting it to int we get -256 or 0xffffff00. Can somebody explain why this should happen? #include <stdio.h> int main (void) { char c = 0xff; printf("%d %x\n", (int)(c<<8),(int)(c<<8)); return 0; } Output is -256 ffffff00 ...

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 ...

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? ...