unsigned

Is wchar_t just a typedef of unsigned short?

for example, does: wchar_t x; translate to: unsigned short x; ...

32 bit unsigned int php

Hello! Does anyone know of a class/library/etc. that can simulate 32 bit unsigned integers on a 32 bit platform in PHP? I'm porting a C lib into PHP and it uses a lot of integers that are greater than the maximum for 32 bit signed int. ...

Unsigned double in C++?

Hello everyone, Why doesn't C++ support unsigned double syntax? Thanks in advance ...

SQlite: Column format for unix timestamp; Integer types

Original problem: What is the right column format for a unix timestamp? The net is full of confusion: some posts claim SQLite has no unsigned types - either whatsoever, or with exception of the 64bit int type (but there are (counter-)examples that invoke UNSIGNED INTEGER). The data types page mentions it only in a bigint example. It als...

method readUnsignedByte in PHP

how get UnsignedBytes in php? In java very easy: readUnsignedByte (Java) ...

A 4-byte Unsigned Int for Sql Server 2008?

I understand there are multiple questions about this on SO, but I have yet to find a definitive answer of "yes, here's how..." So here it is again: What are the possible ways to store an unsigned integer value (32-bit value or 32-bit bitmap) into a 4-byte field in SQL Server? Here are ideas I have seen: 1) Use a -1*2^31 offset for al...

Why this C program outputs a negative number?

I have assigned the complement value in an unsigned variable. Then why this C program outputs a negative number? #include<stdio.h> #include<conio.h> int main() { unsigned int Value = 4; /* 4 = 0000 0000 0000 0100 */ unsigned int result = 0; result = ~ Value; /* -5 = 1111 1111 1111 1011 */ ...

Why doesn't GCC produce a warning when assigning a signed literal to an unsigned type?

Several questions on this website reveal pitfalls when mixing signed and unsigned types and most compilers seem to do a good job about generating warnings of this type. However, GCC doesn't seem to care when assigning a signed constant to an unsigned type! Consider the following program: /* foo.c */ #include <stdio.h> int main(void) {...

Making sure unsigned int/long always execute in checked context in C#

Has anyone found it strange that the default context for uint and ulong is unchecked rather than checked considering that they are meant to represent values that can never be negative? So if some code is trying to violate that constraint it seems to me the natural and preferred behaviour would be to throw an exception rather than return...

Unsigneds in order to prevent negative numbers

let's rope I can make this non-sujective Here's the thing: Sometimes, on fixed-typed languages, I restrict input on methods and functions to positive numbers by using the unsigned types, like unsigned int or unsigned double, etc. Most libraries, however, doesn't seem to think that way. Take C# string.Length. It's a integer, even though...

Why unsigned int contained negative number

Hi All, I am new to C, What I know about unsigned numerics (unsigned short, int and longs), that It contains positive numbers only, but the following simple program successfully assigned a negative number to an unsigned int: 1 /* 2 * ===================================================================================== 3 * 4 *...

JNA unsigned integer by reference gives strange results

I'm currently trying to access a C API using JNA. But I have a problem with unsigned integer parameters that are being passed by reference. So here is the C function in question: int EE_DataGetNumberOfSample(DataHandle hData, unsigned int* nSampleOut); In Java I have: public int EE_DataGetNumberOfSample(Pointer hData, ByReference nS...

How to convert an NSString to an unsigned int in Cocoa?

My application gets handed an NSString containing an unsigned int. NSString doesn't have an [myString unsignedIntegerValue]; method. I'd like to be able to take the value out of the string without mangling it, and then place it inside an NSNumber. I'm trying to do it like so: NSString *myUnsignedIntString = [self someMethodReturn...

Get the signed/unsigned variant of an integer template parameter without explicit traits

I am looking to define a template class whose template parameter will always be an integer type. The class will contain two members, one of type T, and the other as the unsigned variant of type T -- i.e. if T == int, then T_Unsigned == unsigned int. My first instinct was to do this: template <typename T> class Range { typedef unsign...

Why do I get errors when using unsigned integers in an expression with C++?

Given the following piece of (pseudo-C++) code: float x=100, a=0.1; unsigned int height = 63, width = 63; unsigned int hw=31; for (int row=0; row < height; ++row) { for (int col=0; col < width; ++col) { float foo = x + col - hw + a * (col - hw); cout << foo << " "; } cout << endl; } The values of foo ar...

DataType for storing a long serial number (10 bytes)

We have a device which has a 10 byte serial number which must be read into our application and stored into a .net datatype. In the device it is stored as an unsigned 10-byte (80-bit) number. I don't expect we will be performing any mathematical operations on this number, but only displaying it to the user. The .NET framework doesn't ha...

How can I store a sbyte value in a byte variable?

I am programming in C#. I have a sbyte variable. Say it holds -10 which in binary is 11110110. I want to store the binary representation of this value in a byte variable. So when I copy the sbyte (-10) to the byte the bytes value would be 245. If I try to use Convert.ToByte(sbyte) it throws an exception which makes sense. I really don't...

C++: Unsigned negative primitives?

In C++ we can make primitives unsigned. But they are always positive. Is there also a way to make unsigned negative variables? I know the word unsigned means "without sign", so also not a minus (-) sign. But I think C++ must provide it. ...

Unsigned versus signed numbers as indexes

Whats the rationale for using signed numbers as indexes in .Net? In Python, you can index from the end of an array by sending negative numbers, but this is not the case in .Net. It's not easy for .Net to add such a feature later as it could break other code perhaps using special rules (yeah, a bad idea, but I guess it happens) on indexi...

Why is −1 > sizeof(int)?

Consider the following code: template<bool> class StaticAssert; template<> class StaticAssert<true> {}; StaticAssert< (-1 < sizeof(int)) > xyz1; // Compile error StaticAssert< (-1 > sizeof(int)) > xyz2; // OK Why is -1 > sizeof(int) true? Is it true that -1 is promoted to unsigned(-1) and then unsigned(-1) > sizeof(int). Is it true ...