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.

0
votes
0answers
22 views

numpy.float64 type and is_integer() issues

I am writting some python code in sagemath. I just want to parse some values to check if they are integers or not. I'm doing it with is_integer() function. However, only some numbers are matched as ...
-2
votes
2answers
40 views

In Java is it bad practice to pass Integer objects to void functions to simulate pass-by-reference? [duplicate]

I'm writing a function that preserves the image ratio of an image while resizing for a certain screen size. The function should return both the height and width of the optimal image, and then we use ...
0
votes
2answers
40 views

Is there a way, in bash, to search a list of integers for consecutive sequences and remove all but the last numbers in those sequences?

My question is, given a list of integers, is it possible in bash to a) find all the sequences of consecutive numbers, then b) remove all but the last numbers in those sequences? For example, given ...
1
vote
2answers
26 views

Bash, need to count variables, round to 2 and store to variable

I need to count variables, round to 2 and store to variable. Example: I have variable from array ${array[5]} and vat variable defined, I need to calculate simple ( $vat * ${array[5]} + ${array[5]} )...
-4
votes
0answers
54 views

How to return Map<string,Integer> [on hold]

Assignment: Given an array of strings, return a Map<String, Integer> containing a key for every different string in the array, and the value is that string's length. I've tried the following ...
1
vote
1answer
28 views

A problem on “identical()” function in R? How does “identical()” work for different types of objects?

(reproducible example added) I cannot grasp enough why the following is FALSE (I aware they are double and integer resp.): identical(1, as.integer(1)) # FALSE ?identical reveals: num.eq: logical ...
-2
votes
0answers
46 views

Get integers in a single line in c

My input has 2 lines. In the first line I get a single integer number as N. Then in the second line I want to get N integer numbers in a single line which are separated by spaces. How can I do this? ...
1
vote
0answers
40 views

How to get a string when writing a perl hash into a yaml ('1_1' => will be 1_1: in yaml format)

I have a perl script which writes a hash into a file using YAML::DumpFile. The perl hash contains keys like '11': and '1_1':. When I look into the yaml file I see that there is no string anymore, it ...
11
votes
4answers
180 views

To which degree does the C preprocessor regard integer literal suffixes?

Today, I stumbled over something like this: #define FOO 2u #if (FOO == 2) unsigned int foo = FOO; #endif Regardless of why the code is as it is (let's not question the why), I was wondering to ...
0
votes
1answer
32 views

Check if values in pandas dataframe column is integer and write it to a list if not

I have a pandas dataframe with a column which could have integers, float, string etc. I would like to iterate over all the rows and check if each value is integer and if not, I would like to create a ...
0
votes
2answers
40 views

What was this statements mean? “…when a string of character is needed?”?

What does the author try to tell us about the toString() method in this excerpt: The toString() method of the Integer class is automatically used when a string of characters is needed in the next ...
1
vote
1answer
30 views

C# - DateTime / Integer Form Validation (where required field shouldn't be null / empty)

I have an error popping up for the DateTime (DateofBirth) & int (TelephoneNumber) fields. Currently doing a simple library application to register new customer records within the library - trying ...
1
vote
1answer
74 views
+50

Is there a way around casting large integers as string when querying data from BigQuery through R?

Is there a better method for dealing with large integers than casting them as strings when querying data from BigQuery through R via the API? Here's an MVE showing the problem with the integer ...
0
votes
0answers
27 views

Odd behaviour regarding conditional operator [duplicate]

Basically I have this piece of code: double booster = 1d; String result = booster % 1d == 0 ? ((int) booster) + "" : booster + ""; Where result returns either 1 or 1.X depending on input. This is ...
0
votes
1answer
37 views

Angular Integer Validation Giving Problems When Second Period Gets Added

This might have already been answered but I have recently come across this problem when validating an input field that is suppose to only accept integers. (No decimals, meaning no periods and ...
0
votes
4answers
54 views

Is there a way to change the value of the number to text in VBA

I am trying to change the numbers to a 'p' or 'f' based on the score. Not sure how to add images so here is a link https://drive.google.com/file/d/1dKn9mkJa9brZXq2tHz8_ULkgreWsBkTI/view?usp=sharing ...
0
votes
0answers
10 views

Create a 2D bit array of integers from 0 to N

Basically I'm trying to write the binary representation of all numbers from 0 to N in an integer array. For example: suppose N = 7, I need 3 bits at max. I want to make an array that looks like: 0 0 ...
0
votes
0answers
32 views

Convert raw date to ordinal integer in R

I have data frame with dates and I want to convert dates to ordinal integers, > glimpse(df) Observations: 211,797 Variables: 42 $ Churn <fct> No, No, No, No, No, No, No, ...
0
votes
0answers
7 views

I am getting a compile error, integer expression must be constant. Why am I getting it and how would I fix it?

Somewhat new to coding, trying to get LEDS to light up using an array. All ready my first 2 lines of code are not working. When compiling it says the integer expression must be constant? Can anyone ...
1
vote
3answers
43 views

Why I get -2 if I add 2147483647 to itself in java for int and long type? [duplicate]

For integer datatype 2147483647 number is withing the range. I tried a small program as below, int a = 2147483647; int b = 2147483647; int c = a + b; When i print c it prints as -2. I changed the ...
0
votes
1answer
36 views

TypeError: string indices must be integers (Text Data Preprocessing in CSV files for Sentiment Analysis)

I'm kind of new to programming and NLP in general. I've found some code on this website :(https://towardsdatascience.com/creating-the-twitter-sentiment-analysis-program-in-python-with-naive-bayes-...
0
votes
0answers
25 views

XML integer format in odoo form view

I want the user to enter only an integer as a reference, so I created an integer field. The problem is the number prints with thousands separator. I still want to keep the thousand separator for ...
2
votes
1answer
87 views

How to generate integers between min and max using normal distribution?

I learnt that we use unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::default_random_engine generator (seed); std::normal_distribution<double> distribution (...
1
vote
1answer
38 views

How to convert integers represented as string to ASCII symbols?

I have an input string that can look like this: "126022034056098012". It is a result of concatination of ASCII codes of symbols that I've read from some file. The codes are 126 22 34 56 98 12 for ...
-1
votes
2answers
28 views

What wrong with this code of the python programming? [duplicate]

I am new to python. The following code should read an integer into the voting rating: `rating = input('Enter an integer rating between 1 and 10')` My doubt: The problem with the above code is it ...
1
vote
2answers
39 views

How to determine if user input is an number using a boolean function in C

I am trying to figure out how to determine if the user input is a number and not a letter/symbol (A,a,!,@,#,$,%) in C, using a boolean function. The code I am using (if statement) only works for lower ...
-1
votes
1answer
32 views

Can not add elements to ArrayList<Integer>

So I am trying to create a ArrayList of Integers and then iterate variables into it. Only the first value that I specify is being added. private ArrayList<Integer> heights(String detail) { ...
0
votes
2answers
38 views

Trying to write a program to sum the value of an int and a char

I am trying to write a program in C to sum the value of an integer and a character. If the user enters an integer where the character should be, I am expecting my program to calculate the value of the ...
1
vote
1answer
35 views

How to correctly use cv2.DrawMarker function?

I'm getting the error shown below when I try to call my cv2.drawMarker function. ... line_type=cv2.LINE_AA) TypeError: integer argument expected, got float. Process finished with exit code 1 This ...
0
votes
3answers
45 views

Javascript: How cut out part of an integer?

How to cut out part of an integer? What can i do to get an integer 12 or 123 from a variable n let n = 123456;
0
votes
0answers
24 views

How do i convert from integer to binary in standard_logic (no vector) in vhdl

I am inputing into a seven segment display from a clock but the output right now from the clock is in integer. how do i convert it to binary? library ieee; use ieee.std_logic_1164.all; ...
0
votes
0answers
23 views

Is there a way to let the user input ONLY 3 specific numbers? Python [duplicate]

I'm trying to create a 2 - 4 player dice rolling game that I want the user or users to choose how many players are going to be playing the game. I made this to be an input but I only want the user to ...
0
votes
2answers
53 views

I am currently trying to save a set of integers in a int array, by redefining string into numbers, then store it in the array

I am trying to convert input text/numbers (string), which will include any characters, but I want to separate the numbers from the characters and store them into an integer array, once it is converted ...
0
votes
5answers
65 views

Convert integer to float

I am trying to write a function that converts integers to floats, and leave booleans and strings as they are. I have defined the following function: def if_int_to_float(value): if isinstance(...
0
votes
0answers
31 views

How to speed up reading from very large file in c++ code? [duplicate]

I am working with a file which contains 8000 lines.I must read it and use values in my code. This is reading part of code: ifstream fin; fin.open("input.txt"); if(!fin) { cout<<"...
-1
votes
1answer
30 views

How to sort an array of integers based on its binary representation in JavaScript?

I have a task which consists of creating a function in JavaScript which orders an array that receives a list of unordered integers. The function must return an ordered array of integers according to ...
-3
votes
0answers
33 views

How to change maximum value of integer? [duplicate]

EDIT: I believe my question is different from the question marked as duplicate. I'm asking to overwrite the maximum value, not what it is or why. The other question explained what it is, I'm asking ...
0
votes
1answer
25 views

How to compare a '/0' character without it converting to '0'

I have a homework in my computer architecture class, which is basically to write a code in ASM (32 bits) that removes a specific character from a given string and also gives me the new length (...
0
votes
0answers
28 views

How to print an integer vertically?

I need the output of the code to be vertical. from datetime import datetime age = int(input("Enter your age here: ")) num = int(input("how many copies do you want? : ")) x = datetime.now() y= (x....
0
votes
1answer
40 views

using Arrays.sort between Integer.MIN_VALUE, Integer.MAX_VALUE values with Comparator

I have this Java class with int with field, and others fields not needed for this question. class MyInteger { int integer; public MyInteger(int integer) { this.integer = integer; } ...
0
votes
1answer
41 views

Is it possible to make an integer only recieve input for one single number instead of two?

I need to be able to input a series of integers on the same line, I cannot make them characters because I need to add the integers up. #include <iostream> #include<string> using namespace ...
1
vote
1answer
66 views

How to loop certain (variable) number of times?

This question may seem extremely basic, but I'm having a hard time figuring out how to do this. I have an integer, and I need to use a for loop to loop integer number of times. First, I tried - fn ...
0
votes
2answers
54 views

How to pad integer printing with leading zeros?

So i have to make kinda like a timer and this has to be a string and it has to have a 0 before if it is smaller than ten so like 00,01,02...09,10,11 so all numbers are 2 digits. But I've ran into a ...
-3
votes
0answers
26 views

C++: How to get the separate digits of an int number using modulo?

I'm creating a program that is supposed to take each digit in a number and place it in a separate element in an array. For example, if the number was 327, and the array's size is 5, the program should ...
1
vote
1answer
25 views

How to check basic integer order relations in sympy?

I have a (possibly relatively large) set of assumptions about multiple integers like {x > -1, x < 5, x != 2, y > 0, x-2 < y} and I would like to check whether certain other propositions ...
0
votes
0answers
32 views

How to transmit the value of a variable from one arduino to another

I'm setting up a touchscreen interface to control a stepper motor on a micro-injection molding machine I'm building. I've been able to control most of the switches/buttons using push button controls, ...
0
votes
1answer
33 views

Changing array's length as I typed number.(IBM ILOG CPLEX OPL)

Now I'm trying to make a array that change their lengths to what I typed variables. Let me show you a sample code that makes understand you easier. int ANum = 3; // Number of Equipment A int BNum =...
2
votes
2answers
33 views

how can you append a number to a double in swift

I am trying to make a calculator app in swift as a practise for my IOS development course. for that app I am trying to append a number to an existing double or integer after the user pressed on a ...
9
votes
1answer
127 views

What is the default integer type in Rust?

When doing something like: let mut sum = 5 + 10; What is the exact type of sum? Is it an arbitrary-size type which can’t be overflowed?
1
vote
2answers
27 views

How can ı concatenate an integer with desired times in c?

I want to write a function like this: int number_maker(int n, int k) { if(k==1) return n; else { int x = 10; while(n >= x) x *= 10; return ...

http://mssss.yulina-kosm.ru