Questions tagged [integer]

Common datatype in many programming languages for representing a whole number. Use this tag for questions about using, storing, or manipulating integers.

An integer is a whole number that can be negative, positive, or zero. (e.g. ... -2, -1, 0, 1, 2 ...) Use this tag for questions about using, storing, or manipulating integers.

For further reading, here is a Wikipedia article on integers.

11160 questions
4
votes
2 answers

Python TypeError: an integer is required while working with Sockets

Research: Getting a "TypeError: an integer is required" in my script https://github.com/faucamp/python-gsmmodem/issues/39 https://docs.python.org/2/howto/sockets.html Here is my complete error output: Traceback (most recent call last): File…
mee
  • 399
  • 5
  • 8
  • 19
4
votes
1 answer

Returning longest consecutive sequence of ranging integers

The Problem tl;dr - The code below shows an algorithm I'm looking to improve by trying some kind of different approach. Now the long explanation. Given a list of integers, I would like to find every sequence of consecutive integers that are either…
SmeltQuake
  • 124
  • 1
  • 8
4
votes
2 answers

How to clear int[] array in android?

I have an example that calculates total expense and income. There are some values in integer array that converted from a string array. Once I am running the code the sum is 6000 and running again the same code the sum gets multiplied to 12000. How…
Reshmin
  • 85
  • 1
  • 5
  • 17
4
votes
1 answer

How do `intval()` and `(int)` handle whitespace?

The PHP manual on String conversion to numbers says: The value is given by the initial portion of the string. If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). This means that…
user1322720
4
votes
5 answers

how to convert byte value into int in objective-c

Please tell me how to convert bytes to NSInteger/int in objective-c in iPhone programming?
suse
  • 10,255
  • 22
  • 75
  • 112
4
votes
3 answers

Convert a list of strings [ '3', '1', '2' ] to a list of sorted integers [1, 2, 3]

I have a list of integers in string representation, similar to the following: L1 = ['11', '10', '13', '12', '15', '14', '1', '3', '2', '5', '4', '7', '6', '9', '8'] I need to make it a list of integers like: L2 = [11,…
Shamim
  • 41
  • 1
4
votes
1 answer

Printing a frame within frame

I got this assignment in Java and I don't have a single clue on how to do it. The task is to receive an integer n > 0, and to print n number of frames constructed by * inside each other, while the inner frame will have the letter "X" constructed by…
4
votes
3 answers

javax.validation.UnexpectedTypeException: No validator could be found for type:

the below is error we are getting when we try to put validation for size and pattern for Integer type. can you suggest, we need to set the size and pattern validation for Integer type in validator bean.xml 05:58:57,342 ERROR…
Sreeram Gollu
  • 41
  • 1
  • 1
  • 2
4
votes
2 answers

Given an array of integers [x0 x1 x2], how do you calculate all possible permutations from [0 0 0] to [x0 x1 x2]?

I am writing a program that takes in an ArrayList and I need to calculate all possible permutations starting with a list of zeroes, up to the value in the corresponding input list. Does anyone know how to iteratively calculate these values? For…
user319951
  • 61
  • 1
  • 4
4
votes
6 answers

Does ( 0 < 0 ) return true?

ill have an if statement if (int1 < int2) {} else {} I want the else statement to run if both int1 and int2 are 0..
Matt
  • 3,838
  • 9
  • 36
  • 61
4
votes
1 answer

Haskell convert string to integer list

I have the following string [1..5] and I want to convert it to the Integer list [1,2,3,4,5]. I tried doing this using read but that does not work. Is there any simple trick to convert such a list to an Integer list or will it require a parser?
surfer1311
  • 231
  • 1
  • 4
4
votes
2 answers

Translating an integer and a character into several forms in C

In my program I have to: Ask a user for a number and then display that number, then display it as a decimal, an unsigned octal, a hexadecimal, a floating point, a float to two decimal places, then float to three decimal places, a floating point…
Zach Ross
  • 69
  • 8
4
votes
1 answer

PHP array: integer index vs string index

Is there any difference between integer index and string index of PHP arrays (except of course the fact that the latter is called associative array)? So for example, what are the differences between the following two arrays: $intIndex[5] =…
CluelessNoob
  • 610
  • 1
  • 8
  • 18
4
votes
1 answer

Avoid converting numbers to characters in Erlang

I am having trouble with Erlang converting listed numbers to characters whenever none of the listed items could not also be representing a character. I am writing a function to separate all the numbers in a positive integer and put them in a list,…
Fefo
  • 43
  • 6
4
votes
4 answers

Smalltalk: how to check wether a string contains only numbers?

so basically I have some input possibilities for the user where should only numbers be accepted, otherwise the user will be alerted his input was incorrect. the input is considered a String when I read it out using a callback. now I want to check…
roqstr
  • 544
  • 3
  • 8
  • 21
1 2 3
99
100