Questions tagged [integer]

Common datatype in many programming languages for representing both negative and non-negative whole numbers. Use this tag for questions about using, storing, or manipulating integers. For 64-bit integers, use the [long-integer] tag instead.

integer
3,350 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1 vote
0 answers
78 views

How to efficiently store and multiply arbitrarily large integers mod n

I want to implement a datastructure struct bignum to store arbitrarily large integers. It should also be possible to efficiently multiply the integer modulo n. I am not looking for any libraries. I ...
Ben Heckmann's user avatar
1 vote
5 answers
440 views

Python - changing the data type of INT to STR not working

Whenever I run my code an error comes which states "TypeError: can only concatenate str (not "int") to str" this comes in the output = output + text.yellow + number line. I ...
Ashmeet SIngh's user avatar
1 vote
0 answers
71 views

Why does this code convert characters into ASCII numbers?

I have used this code and it works perfectly and simple, but I want to know how it works: char caracter; int m; cout << "Ingrese un caracter : "; cin >> caracter; m = (int)...
Henry Villa's user avatar
1 vote
2 answers
181 views

Printing string inside of an integer array

I am trying to print a string in between integers. How should it be done
fm_'s user avatar
  • 19
1 vote
1 answer
3k views

TypeError: cannot convert the series to <class 'int'> python

In this function I'm trying to convert a series object to an int object. But when I try it I keep geting this error message TypeError: cannot convert the series to <class 'int'>. I have already ...
Raul Lopes's user avatar
1 vote
0 answers
574 views

Python: data type conversion of numpy array containing NaN

I am incurring in a behaviour that I cannot comprehend. Problem description I was hoping that trying to convert the data type of an array to integer would raise the "classic" ValueError: ...
Pietro D'Antuono's user avatar
1 vote
0 answers
596 views

Kotlin: use an object's property as "object value" instead of the object reference (like the Int object does)

For serializing/deserializing purposes, I have special classes like UInt16 which internally represents a UShort Kotlin data type. This class has special methods for deserializing it from resp. ...
andimeier's user avatar
  • 1,233
1 vote
1 answer
29 views

wrong result shown in converting float to integer in pd

hi i want to ask why i convert to int but the result still remain as float64
Gekyume X's user avatar
1 vote
0 answers
81 views

Converting an integer to a string of escaped hex (NOT bytes)

I am trying to come up with a way to convert an integer to a string of escaped hex, as if it was coded that way... for example: x = '\xab\xcd\xff\xff' I have tried the following function, but it ...
steve's user avatar
  • 11
1 vote
0 answers
38 views

Can anyone tell me the problem of this code (it is to write even and odd numbers in separate files.)?

I want to print even and odd in separate file only up to 50.Given below is the program. #include<stdio.h> #include<conio.h> int main() { FILE *fp1,*fp2,*fp3; int i,n; fp1=fopen(...
Maya Devi's user avatar
1 vote
2 answers
782 views

How to convert data containing various types of int into Swift Int

I receive Data type object which inside is list of uint8_t, uint16_t, uint32_t(mix typed list). I need to convert this data into swift array of Int. I cannot do the followings since data contains ...
Bigair's user avatar
  • 1,562
1 vote
1 answer
81 views

Python will sometimes throw 'invalid literal for int() with base 10:' error when converting string to int and sometimes won't

I am writing a Python ros node to read encoder data from an Arduino, and publish it as a ros topic in Python. The Arduino is writing data fine over the serial port, but sometimes the python script won'...
skippy57344's user avatar
1 vote
1 answer
383 views

Why Python only uses 30-bit from every 32-bit unsigned integers instead of using up all 32 bits?

I found that Python only use 30-bit in every 32-bit unsigned integer from arrays. If all 32 bits are used it can represent a larger integer, but Python chooses to leave two bits remained. Why does ...
oeter's user avatar
  • 698
1 vote
0 answers
55 views

C++ ignores the second input if the type of the first input in not correct

This is the code: #include <iostream> using namespace std; int main() { int var1; float var2; cout << "input var1:"; cin >> var1; cout << "...
Ste.02's user avatar
  • 13
1 vote
0 answers
89 views

Java generate and track small reusable unique numbers for business use cases

For inventory management we use a key/id called item number It is a consecutive number starting from 1 It must be unique The datatype is int It is not a database key It should get reused after ...
Sebastian Riemer's user avatar
1 vote
0 answers
203 views

How are maps and sparse arrays implemented under the hood for JavaScript in v8 (to determine which would be more optimized for a specific use case)?

I am having to figure out the best way to store objects when using an integer or BigInteger as a key. This leaves me with 3 choices for what I care about: objects, maps, or sparse arrays. I think I ...
Lance's user avatar
  • 77.2k
1 vote
1 answer
386 views

transforming a weekday integer to a string - swift

I currently have an array of weekdays that represent integers which I will trigger a notification on that weekday let weekdays:[Int] = [1,4,7] in dateComponents, weekdays represent a number so for ...
user17928877's user avatar
1 vote
0 answers
653 views

C++ Convert to hex and store the result in uint8_t

std::stringstream sstream; uint8_t data[1] = { }; int x =1; sstream << "0x" << std::hex << x; //sstream = 0x04b35cc8 "0x1" why the sstream not be only ...
user216905's user avatar
1 vote
1 answer
58 views

float to int conversion oddities in .Net

See this code: public static void Main() { float test = 1.8f; Console.WriteLine(test); // 1.8 int intTest = (int)(test * 100); Console.WriteLine(intTest); // expected result: 180, ...
ava's user avatar
  • 71
1 vote
1 answer
195 views

Logic Puzzles with Modern Optimization Algorithms

I have the following "logic puzzle" (I think this is considered as a "scheduling problem"): In this problem, there are 5 basketball players - provided some clues about their ...
stats_noob's user avatar
  • 5,461
1 vote
0 answers
61 views

retrieve the state of checkbox as int from SQLite in android studio and show the checkbox state in the activity

i am trying to do health activity in which there is 30 day challenge with 30 checkbox to check one every day ..i need to store the state of checkbox in SQLite and then show the state in the activity i ...
azooza's user avatar
  • 11
1 vote
0 answers
1k views

Convert Image to Uint8List Flutter

How to convert variable Image type to Uint8List? The variable get its value from shared preferences when App start like this: String? img = prefs.getString('image'); Image imageOfBillHead = Image....
mhmd's user avatar
  • 405
1 vote
0 answers
520 views

casting INT to Datetime date is 2 days off

So I am parsing out a large text field with several dates in it. the date format comes out like "44445" which should be "9/6/2021" but when I convert to datetime in Microsoft SQL ...
Dave's user avatar
  • 11
1 vote
3 answers
993 views

Print only the numbers in the string in python

I need to print only the numbers in the string and I don't know how to do it I mean for example mystring="ab543", How to get 543 as int? I tried something like that my_string="ab543&...
Funnycallsw's user avatar
1 vote
4 answers
189 views

How to get only integer or float input

I am trying to make a calculator in python. However, I want the user to be able to input an integer or float. But not a string, how can I do that? This is my current code, however, the if statement ...
nutella1555's user avatar
1 vote
4 answers
99 views

Question about how pointers work in C with a problem

I'm solving a problem for class in C where I return the biggest value from an unsorted array and the index of that value gets stored in the pointer index_ptr. Here is the code I built: int ...
ARainyCloud's user avatar
1 vote
0 answers
47 views

NA_integer as a result of a sum

I need some help with a mystery that I'm dealing with. Sorry if it is a beginner question , but I'm just starting to work with R. I'm doing a work of analyzing coronavirus cases in the world using the ...
Brot's user avatar
  • 11
1 vote
0 answers
246 views

every k-th digit of a number in c

Given some natural numbers n and k, my goal is to write a C program that outputs a number formed by every k-th digit of n. I wrote a program as follows: #include <stdio.h> #include <math.h>...
Sgg8's user avatar
  • 201
1 vote
2 answers
82 views

changing from string numbers in a list to int and sum them up. Number strings are separated by characters in the string it self where numbers

Implement a function called add_even_numbers(). The function takes in a list of strings called str_list (type: list) as its parameter, where each string in str_list contains a sequence of positive ...
tmiwetmiwtwete's user avatar
1 vote
1 answer
96 views

Scipy.optimize: parsing error occurs when maxiter is a large integer

I am implementing a shooting method type problem and i used scipy.optimize.bisect from the scipy module.To achieve higher precision i wanted to go to large iteration numbers, but frequently got the ...
user16641273's user avatar
1 vote
3 answers
342 views

Excel VBA Solver Error (specificly integer constraint)

Sorry if my english grammatically is not correct (I am not from UK or USA). I try to set up the Excel solver while using VBA code. So far, this is the macro I set up: Sub solver() SolverReset ...
Frank's user avatar
  • 11
1 vote
1 answer
831 views

Sorting a list of integers using Z3 python

I'm looking for the fastest way to sort a list of integers using Z3. So far, I currently implemented two different algorithms: the first one can only handle lists that do not contain any duplicate ...
tpaviot's user avatar
  • 11
1 vote
0 answers
575 views

ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to supported types--want to downgrade integer columns

I am trying to optimize my dataframe by downcasting the columns of dtype 'int64' to 'unsigned' except for one column that actually has negative values. For that one column I want to just convert it ...
LeeZee's user avatar
  • 107
1 vote
3 answers
3k views

Codility error: Invalid result type, Integer expected, NilClass found

EDIT: SOLVED BY STEFAN BUT: Now, the only questions left are: Why has the shorter solution such a poor performance (results: 100%, performance: 32%, result: 66%) , while the longer version performs a ...
badde-media's user avatar
1 vote
2 answers
672 views

Is it possible to assign an int value greater than 255 to a char?

#include <iostream> using namespace std; int main(){ int f = 1; int s = 500; char d = 256; // This line gives me overflow error char c = s; // But it does not. cout <&...
Vembu karthick's user avatar
1 vote
0 answers
242 views

Force corrplot color label to display integers only

I'm using corrplot and trying to get only integers in the color label. I'm plotting a non-correlation matrix, and I want my color label to contain a range greater than the max() in the matrix (which ...
XiBon's user avatar
  • 11
1 vote
1 answer
874 views

How to convert int to char* in Ardunio

So I need to convert an int value into a char* value. Here is my code so far: void setup(void) { Serial.begin(115200); char* host = "esp32"; SerialBT.begin("test"); ...
Lyam Dexter Mosnier's user avatar
1 vote
0 answers
262 views

Snowflake - a union condition of integer and varchar types lead to decimal datat type of a column

Input: we have two tables with ID fields. In one table this field has an integer data type, in another - a varchar. And when we combine these data with a union/union all condition, the output data ...
user2588792's user avatar
1 vote
0 answers
61 views

Entered a number as int, but it outputs not the same (returns 256)

The following is my C++ code for entering integer numbers that have three figures. #include <iostream> #include <string> using namespace std; int main() { int a; char b[3]; ...
Kimpro's user avatar
  • 81
1 vote
1 answer
61 views

How to write a rule that validates an integer with or without a sign?

Here are my test cases. The test case with no sign fails. I can't figure out how to make it pass. [1] ?- signedIntegerProduction([3,2,2]). false. [1] ?- signedIntegerProduction([+,2,2]). true. [1] ...
nicomp's user avatar
  • 4,451
1 vote
0 answers
16 views

Spinner options for a math calc with other inputs

I have a spinner drop down list in lbs or kgs how do I then get the user to input the numerical value, so I can then do a math calc with other spinner inputs . bit of a novice so any help appreciated.
JPP2012's user avatar
  • 11
1 vote
0 answers
191 views

'list' object cannot be coerced to type 'integer' -- WRS2 package

I come across the below error when trying to use a function of WRS2 package. Error in sequence.default(piece, ...) : 'list' object cannot be coerced to type 'integer' Below is the code. ...
Ann Ng's user avatar
  • 45
1 vote
1 answer
46 views

I need help converting a string to an integer

Good day, I have an array adapter in Activity1 in my AndroidStudio project. I would like to transfer two specific items from the ArrayAdapter (in positions 1 and 2) to Activity2 with an intent. (the ...
sininsinsinini's user avatar
1 vote
0 answers
709 views

How to make larger integers on MicroPython?

I'm working on a personal project on Raspberry Pi Pico. I try to make mandelbrot set explorer on it. But I have a limit right now. On my searching, I see MicroPython stores integers only 32 bits but I ...
SMD_Human's user avatar
1 vote
1 answer
1k views

x_input=numpy.array(), TypeError: 'int' object is not subscriptable

I am running the python code and facing that error. I am trying to resolve it but I couldn't because I am not familiar with python. So, guide me and suggest a proper solution. I want to calculate the ...
Syed Ali Abbas's user avatar
1 vote
4 answers
757 views

Python: How to change the data type of every element in every sublist of a list. In this case: int to str

Given a list like list1 = [[1,2,3],[4,5,6]], in order to get back [['1','2','3'],['4','5,'6']], I have tried this: for i in list1: for j in i: j = str(j) list1 which does nothing to the list:...
101is5's user avatar
  • 329
1 vote
0 answers
29 views

How to access ImageView that is in a Layout Integer in a ViewPager

I made an Adapter for my ViewPager which gets its values from an Integer in my MainActivity. The problem is I can't access the Image view inside that layout. Here you can see my codes: ///*** The Java ...
John's user avatar
  • 11
1 vote
0 answers
26 views

How to extract a number from an existing file using Tokenizer (java)

I have this piece of code to extract lines from an existing file using Tokenizer: String line = ""; StringTokenizer inLine; However, I also need to extract integers. How to I extract ...
user388777's user avatar
1 vote
0 answers
76 views

understanding VBA loops

I am trying to understand what the following VBA loop is doing: Sub iterate_dev() Dim i As Integer For i = 1 To 10 [paste1] = [copy1].Value [paste2] = [copy2].Value Next i End Sub I did a step ...
MikeB's user avatar
  • 11
1 vote
2 answers
963 views

How do I include an int inside a getline();

Just a simple question, how do I include int values inside a getline()? I have searched online but couldn't find any that helps me. I am reading off a txt file. It is a row of numbers. For eg: 1,2,3,...
Hakim Muhaimin's user avatar

1
3 4
5
6 7
67