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
4 answers

How do you convert UINT8 to UINT32 in C++?

I have a value of type UINT8 and I would like to make it UINT32. Would my following code be considered correct, valid, efficient and safe? UINT32 convU8toU32(UINT8 *number) { UINT32 result = *number; return *result; } Please notice that I'm a…
M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
3
votes
2 answers

Rounding off and recast it as integer

double num1=3.3; double num2=3.8; //print output and round off cout<
Sylar
  • 45
  • 7
3
votes
1 answer

mysql order by integer and varchar

I got a field with sizes(VARCHAR). The sizes can have int and string values, e.g. (1, 2, 3-4, X, XL, M, ...). When i use the normal order by function of mysql the output is the following: 1,10,11,2, 44-46, L, M, S, XL, XXL The values that does not…
ipsum
  • 1,042
  • 7
  • 17
3
votes
2 answers

Counting number of times an int occurs in an array (Java)

I'm trying to count the number of occurences of ints, one to six inclusive, in an array of size 6. I want to return an array with the number of times an int appears in each index, but with one at index zero. Example: Input: [3,2,1,4,5,1,3]…
arnbobo
  • 2,515
  • 2
  • 12
  • 18
3
votes
3 answers

Pandas error trying to convert string into integer

Requirement : One particular column in a DataFrame is 'Mixed' Type. It can have values like "123456" or "ABC12345". This dataframe is being written into an Excel using xlsxwriter . For values like "123456", down the line Pandas converting it into…
SanBan
  • 635
  • 5
  • 12
3
votes
1 answer

Using Int type vs. Integral constraint. Advantage?

Consider these (more or less) equivalent type signatures: f1 :: [a] -> Int -> a f2 :: Integral b => [a] -> b -> a f2 is more general than f1, and that is a big advantage, but is there an advantage of f1 over f2? It seems that in the solutions to…
kes
  • 5,983
  • 8
  • 41
  • 69
3
votes
1 answer

Sorting 32 bit ints is as fast as sorting 64 bit ints

Here are things I believe are facts: Quick sort should be fairly cache friendly. A cache line of 64 bytes can contain 16 32-bit ints, or 8 64-bit ints. Hypothesis: Sorting a vector of 32-bit integers should be faster than sorting a vector of…
Klein
  • 75
  • 4
3
votes
3 answers

Check if string is numeric in one line of code

I'm working with a DNN form-building module that allows for some server-side code to be run based on a condition. For my particular scenario, I need my block of code to run if the first 4 characters of a certain form text are numeric. The space to…
TheIronCheek
  • 1,077
  • 2
  • 20
  • 50
3
votes
1 answer

How many bytes are in a Location ID from the Instagram API?

I cannot find any decent documentation on the Instagram API about this. I know it returns a number through the API which is usually a 2^32 bit int, but once in a while I will get a number that is 2^64. I want to store these numbers in my Cassandra…
Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53
3
votes
0 answers

Why can't `NumberFormatter` display maximum `Int` value?

This code prints "eighteen quadrillion fourteen trillion three hundred ninety-eight billion five hundred nine million four hundred eighty-one thousand nine hundred eighty-four", but the numeric value of Int.max is 9223372036854775807. let formatter…
Tone416
  • 540
  • 3
  • 10
3
votes
6 answers

Printing number names from 0-999999

So I was given a little task, I had to write a program in Python that prints a number's name from 0-999999. But I ran into some problems, and I'd love to get your ideas and help. This is what I have written so far: numbers = {1: 'One', 2: 'Two', 3:…
trizz
  • 57
  • 6
3
votes
5 answers

Does casting random integers to short give a uniform distribution?

As the title explains, I am looking to generate a series of random short values. Because there is no Random.nextShort() function, the easiest way to do what I want seems to be to cast integers to short, using: Random rand = new Random(int…
DylanJaide
  • 385
  • 1
  • 3
  • 13
3
votes
1 answer

How to force Pandas to read numbers as "int64" instead of "float64"

I have an issue where all of the legacy code I have written no longer works. I have pandas reading an Excel file, and instead of reading as int64, it now reads as float64. It is an issue because I cannot perform .merge or .isin on different data…
Matt
  • 33
  • 5
3
votes
2 answers

How to convert BufferedImage to an int[]?

I'm looking to send over an Object that has a BufferedImage through a socket. BufferedImage is not serializable, so it needs to be converted to a serializable data type, and then back again. I have looked a lot online, and byte[] seems to be the go…
Dak31
  • 82
  • 8
3
votes
3 answers

Converting 2 bytes to signed int

Is their any way to convert 2 bytes to signed int? I know we can convert a byte to signed int in following way byte B1= 0xFF; int r = Convert.ToSbyte((sbyte)B1); but what about 2 bytes to signed int? For example -260 is 0xFC, 0xFE
prattom
  • 1,625
  • 11
  • 42
  • 67