Questions tagged [int]

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

int is a data type that represents an integer (a whole number - not a fraction).

int data types may vary based on:

  • the number of bits used to represent them - 16, 32, etc.
  • whether they allow both negative and positive values (signed integers) or only positive (unsigned integers).

In many (but not all) languages, integers are limited to a specific range due to the way they are stored - for instance, an ISO C 32-bit signed integer can store values from −2,147,483,648 to +2,147,483,647 (-2³¹ to 2³¹-1).

This keyword is often used in C-like languages (including C, C++, Golang, etc.)

9665 questions
3
votes
2 answers

C/C++ Compiler that allows int width selection

Does anyone know of a modern native Windows C or C++ compiler that allows you to select between 16-bit and 32-bit type int? I encountered a cross-compiler back in the 80s that had this feature but I need a native compiler. As part of teaching my…
BenevolentDeity
  • 587
  • 6
  • 15
3
votes
5 answers

Converting string to int[]

I was wondering how I could convert numbers in a string value to an int[]. I have the following numbers stored in a string: 1,2,3,4 But I was wondering how I could get these numbers stored in an int[] so each value is stored into the int array.
BytePhoenix
  • 47
  • 1
  • 6
3
votes
2 answers

Why converting from string to int results in weird value

I'm new to F# and I was having trouble finding the last element of an number-string and converting that element to an int. So if the string was "123", then I would want to get back 3. However, this code: let s (a : string) = let x = a.[0] …
user123082
  • 33
  • 3
3
votes
2 answers

concatenate two integers into a char * in C

Having forgotten my C knowledge now, having a really hard time figuring out how to do the following: int a = 5; //getting value from a function int b = 1; //from a function what I want to have is: char * returnstring = "5:1"; //want to return…
samsamara
  • 4,630
  • 7
  • 36
  • 66
3
votes
4 answers

Working with blocks?

In an interview I recently attented I was asked to predict the output of a code segment. Even if I got it right, I was not able to explain how got it. This is the code segment. int num =2; int (^ myblock)(void)=^{ return num*5; }; NSLog(@"my…
user3292590
  • 103
  • 5
3
votes
2 answers

What is the best way to send a method a dynamic number of variables?

I have a java program with a method that will consistently receive a different number of int values. What is the best way to send it the ints?
localplutonium
  • 260
  • 3
  • 13
3
votes
2 answers

Merge 2 Lists of different types using LinQ

I have 2 lists. If both of them are of type string. I can merge them by using something like: List myCars = new List { "Yugo", "Aztec", "BMW" }; List modeList = new List { "BMW", "Saab", "Aztec" }; var carConcat =…
T D Nguyen
  • 7,054
  • 4
  • 51
  • 71
3
votes
4 answers

Convert an integer into a string of its ascii values

Given a number number such that its digits are grouped into parts of length n (default value of n is 3) where each group represents some ascii value, I want to convert number into a string of those ascii characters. For example: n …
3
votes
2 answers

Make Int round off to nearest value

I've got two Int values (they have to be Ints) and I want them to round off to the nearest value when in an equation; var Example = Int() var secondExample = Int() Example = (secondExample / 7000) This equation makes the variable Example always…
Rappe Stegarn
  • 347
  • 1
  • 4
  • 10
3
votes
4 answers

how to show a message in screen if the number is int or double in java?

im doing a homework of learning java from a university and i dont know how to do this im trying to put a message if the user enter a number like "11" or wherever show a message like "this number is integer: 11" but if i write in screen 22,4 show a…
Alexander
  • 37
  • 1
  • 4
3
votes
1 answer

Convert Java long to int64 in C++

I am receiving some numerical data from a Java client via socket connection on C++ server. When I receive 4 byte int type data, what I need is just using ntohl() function or reverse the bit order to convert to c++ int type. However, I'am having…
Vitt Volt
  • 337
  • 4
  • 17
3
votes
0 answers

What does Int use three bits for?

Unlike many langauges where Int is in the range 231 to 231-1 using one bit for the sign bit, Haskell instead uses the range 229 to 229-1, or in other words 29 bits + 3 bits for something else... I'm guessing one of those three are the sign bit, but…
Electric Coffee
  • 11,733
  • 9
  • 70
  • 131
3
votes
4 answers

C++ Handling big numbers

Okay, I have to do simple task for my c++ class. Two functions, first is Fibonacci sequence, second some random sequence (finding e). It looks like this: #include #include #include #include void fib(int…
minecraftplayer1234
  • 2,127
  • 4
  • 27
  • 57
3
votes
3 answers

Convert array of int to array of chars - Python

I am trying to convert a set literal of integers into that of chars. For example, if the array {0,1} is given as an input, I would like to firstly check if the individual elements are chars and if not convert them into chars so that I get {'0',…
Seb
  • 481
  • 2
  • 6
  • 18
3
votes
1 answer

what does int() on a number starting with 0 do?

The following two lines will both print out 12: print int(12) print int("012") Why does the following print 10? print int(012)
Haplo
  • 33
  • 4