integer

Increment a Integer's int value?

How do I increment a Integer's value in Java? I know I can get the value with intValue, and I can set it with new Integer(int i). playerID.intValue()++; does not seem to work. Note: PlayerID is a Integer that has been created with: Integer playerID = new Integer(1); ...

Integer won't increment?

Okay, so I have a client/server test going on, and I am passing the Integer playerID to a thread where it gives the int value to a simple Player object, than increments playerID by 1. public static void main(String[] args) throws IOException { Vector<Player> player = new Vector<Player>(); SlickServer ss = new SlickSer...

Base conversion

I know usual conversion from oct_to_dec. Some smarter way? ...

How to check whether a int is not null or empty?

I really dont know this is possible or not. But I am strucking in a place where i want to check a int value is null or not, to call different methods. Is there any way to do it? Actually that variable comes from a browser with a null value. I cannot change the int declaration to Integer. Because it has it own consequences. Any suggest...

Why int32 has max value 2^31 -1

Possible Duplicate: 2's Complement - Defined I know int32 is has a lenght of 32 bytes. I assume it has 2^32 values but as half of them needs to be under zero, I guess it has something to do with this. I would like to know why exactly int32 has max. positive number 2^31 -1. ...

Integer to string in C without preallocated char array

Please, look at the following code that just convert an unsigned int to a string (there may be some unhandled cases but it's not my question), allocating a char array in the heap and returning it, leaving the user the responsibility to free it after the use. Can you explain me why such function (and others similar) do not exist in C sta...

Parsing element of a string array into a int

As the question says am trying to parse one of the elements of an string array into a int variable. although the code is right in terms of syntax, when I try to run it, I get the following error message. Error 1 Building content threw FormatException: Input string was not in a correct format. at System.Number.StringToNumber(St...

How to use Int64 in C#

Hi,The question is easy! How do you represent a 64 bit int in C#? ...

checking an integer to see if it contains a zero

Given an integer, how could you check if it contains a 0, using Java? 1 = Good 2 = Good ... 9 = Good 10 = BAD! 101 = BAD! 1026 = BAD! 1111 = Good How can this be done? ...

Floating point and integer ambiguity

I have a function (and a constructor) that should be able to take integer and floating point values. In fact I want it to take an int64_t or a long double, so what I want is, class Foo { public: Foo(int64_t value=0); Foo(long double value); }; However if I do this and try Foo f = 1; the compiler complains about the convers...

Convert INT to DATETIME

I am trying to convert a date to datetime but am getting errors. The datatype I'm converting from is (float,null) and I'd like to convert it to DATETIME. The first line of this code works fine, but I get this error on the second line: Arithmetic overflow error converting expression to data type datetime. CAST(CAST( rnwl_efctv_dt AS I...

integer range in c

why integer has a range between 0 and 32768? ...

convert string to integer in c++

Hello I know it was asked many times but I hadn't found answer to my specific question. I want to convert only string that contains only decimal numbers: For example 256 is OK but 256a is not. Could it be done without checking the string? Thanks ...

Character by Character Input from a file, in C++

Is there any way to get input from a file one number at a time? For example I want to store the following integer in an vector of integers since it is so long and can't be held by even a long long int. 12345678901234567900 So how can I read this number from a file so that I can: vector<int> numbers; number.push_back(/*>>number goes h...

Trimming a string of Int

In my program i want to input a string of integer e.g 2107900000. I want to get its length and then want to remove all the 0's and 1's. ...

reading two integers in one line using C#

i know how to make a console read two integers but each integer by it self like this int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); if i entered two numbers, i.e (1 2), the value (1 2), cant be parse to integers what i want is if i entered 1 2 then it will take it as two integers ...

modf returns 1 as the fractional:

I have this static method, it receives a double and "cuts" its fractional tail leaving two digits after the dot. works almost all the time. I have noticed that when it receives 2.3 it turns it to 2.29. This does not happen for 0.3, 1.3, 3.3, 4.3 and 102.3. Code basically multiplies the number by 100 uses modf divides the integer value by...

Random number generator that generates integers for Java

hi, I want to generate some random integers in Java, but this according to some distribution laws. More specific: I want to generate some random integers for gaussian distribution. I found out only generators which return double results for the gaussian distribution. Why is that? I want to generate some random integers between some li...

whats the easiest way to convert "6.00000000000000" to an integer property

i have an Person object with an age property (int) i am parsing a file and this value is coming in this format "6.00000000000000" what is the best way to convert this string into an int in C# Convert.ToInt32() or Int.Parse() gives me an exception: Input string was not in a correct format. ...

Counting bits in a int - why does this code work?

I was trying to learn more about bits, and I came across this example. How does this code work to count the bits? (My C is very rusty, by the way). unsigned int v; // count the number of bits set in v unsigned int c; // c accumulates the total bits set in v for (c = 0; v; v >>= 1) { c += v & 1; } ...