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 ...
My component is handed a long value that I later use as a key into a cache. The key itself is a string representation of the long value as if it were unsigned 64-bit value. That is, when my component is handed -2944827264075010823L, I need to convert that into the string key "15501916809634540793".
I have a solution, but it seems brute ...
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...
I myself am convinced that in a project I'm working on signed integers are the best choice in the majority of cases, even though the value contained within can never be negative. (Simpler reverse for loops, less chance for bugs, etc., in particular for integers which can only hold values between 0 and, say, 20, anyway.)
The majority of ...
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 ...
I found this in the code I'm working on at the moment and thought it was the cause of some problems I'm having.
In a header somewhere:
enum SpecificIndexes{
//snip
INVALID_INDEX = -1
};
Then later - initialization:
nextIndex = INVALID_INDEX;
and use
if(nextIndex != INVALID_INDEX)
{
//do stuff
}
Debugging the code, t...
I work with an application which uses rather big numbers and I need to store data as an unsigned 64-bit integer. I prefer to just store it without worrying about bit manipulation or anything like that so different programs can use the data in different ways.
...
Let's say that I'm writing a library in C# and I don't know who is going to consume it.
The public interface of the library has some unsigned types - uint, ushort. Apparently those types are not CLS-compliant and, theoretically speaking, there may be languages that will not be able to consume them.
Are there in reality languages like ...
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...
I want to see the type of a variabe whether it is unsigned 32 bit,signed 16 bit etc.
How to view...
...
What is the correct way of iterating over a vector in C++?
Consider these two code fragments, this one works fine:
for (unsigned i=0; i < polygon.size(); i++)
{
sum += polygon[i];
}
and this one:
for (int i=0; i < polygon.size(); i++)
{
sum += polygon[i];
}
which generates warning: comparison between signed and unsigned integer ...
Why doesn't Java include support for unsigned integers? It seems to me to be an odd omission, given that they allow one to write code that is less likely to produce overflows on unexpectedly large input. Furthermore, using unsigned integers can be a form of self-documentation, as they indicate that the value that the unsigned int was i...
In C++, I enjoyed having access to a 64 bit unsigned integer, via unsigned long long int, or via uint64_t. Now, in Java longs are 64 bits, I know. However, they are signed.
Is there an unsigned long (long) available as a Java primitive? How do I use it?
...
I know, the question seems to be strange. Programmers sometimes think too much. Please read on...
In C I use signed and unsigned integers a lot. I like the fact that the compiler warns me if I do things like assigning a signed integer to an unsigned variable. I get warnings if I compare signed with unsigned integers and much much more.
...
Can somebody clarify the C# is keyword please. In particular these 2 questions:
Q1) line 5; Why does this return true?
Q2) line 7; Why no cast exception?
public void Test()
{
object intArray = new int[] { -100, -200 };
if (intArray is uint[]) //why does this return true?
{
uint[] uintArray = (uint[])in...
I have seen this mentioned a lot but I have never figured out what it meant. Can anyone help me out?
...
Hello,
Strange how I can do it in C++,but not in C#.
To make it clear,i'll paste the two functions in C++ and then in C# and mark the problematic lines in the C# code with a comment "//error".
What the two function does is encoding the parameter and then add it in to a global variable named byte1seeds.
These are the functions in C++
...
I know unsigned int can't hold negative values. But the following code compiles without any errors/warnings.
unsigned int a = -10;
When I print the variable a, I get a wrong value printed. If unsigned variables can't hold signed values, why do compilers allow them to compile without giving any error/warning?
Any thoughts?
Edit
Comp...
Hi.
What is the best way of converting a unsigned char array to a float array in c++?
I presently have a for loop as follows
for (i=0 ;i< len; i++)
float_buff[i]= (float) char_buff[i];
I also need to reverse the procedure, i.e convert from unsigned char to float (float to 8bit conversion)
for (i=0 ;i< len; i++)
char_buff[i]...
How do you determine the length of an unsigned char*?
...