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.
13,355
questions
2
votes
2
answers
39
views
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.Integer; Concatenate/Merge/join two Integer[] Array
I'm trying to concatenate/merge two Integer[] array and store it in an other Integer[]. But I'm getting bellow error at run time.
Exception in thread "main" java.lang.ClassCastException: ...
0
votes
0
answers
20
views
File can't combine strings & ints [duplicate]
I am trying to combine Strings and Int to find a file, but I am trying to see if a save file exists, I don't know why it won't work
here is the code, file.open("Save" + saveNum + ".dat&...
0
votes
0
answers
2
views
Runtime Error: 'tuple' object cannot be interpreted as an integer
from keras.applications.vgg16 import VGG16
from keras.layers import GlobalAveragePooling2D, Dense, Dropout, Flatten, Input, Conv2D, multiply, LocallyConnected2D, Lambda
from keras.models import Model
...
0
votes
0
answers
27
views
Generic that can be created from 1
I have a use case where I need a generic, that can be created from a literal 1.
What trait bounds do I need for that?
Conditions:
Standard library only - no external crates.
Should work for any built-...
-1
votes
1
answer
24
views
Using an int in a string PHP
Hey I'm currently using wordpress to create a website and as I'm new to PHP I'm having some trouble adding an integer into a shortcode command. This is the code I'm currently using:
<?php $store_id ...
-2
votes
0
answers
34
views
Taking input as a few lines of integer and storing it in a 2D array in C++ [closed]
How can I take input as a few line of integers and store it in a 2D array in C++?
for example, if my sample input is like :
2 3 4 5
8 9 11 13
7 1 0 10
12 14 15 6
Now I want to take this input as a ...
0
votes
0
answers
11
views
NoReverseMatch at / Reverse for 'story' with keyword arguments '{'id': ''}' not found. 1 pattern(s) tried: ['story/(?P<id>[0-9]+)\\Z']
I'm getting this error:
NoReverseMatch at / Reverse for 'story' with keyword arguments '{'id': ''}' not found. 1 pattern(s) tried: ['story/(?P<id>[0-9]+)\\Z']
For this line in my template: <...
0
votes
0
answers
18
views
Is there a way to generate an integer numpy array by multiplying a float array with one that will remove the need of a float for result?
multiplication of a numpy float array for an integer and producing an integer array with results
standard multiply function, when starting with a float array, generates a float result, yet i start ...
0
votes
0
answers
29
views
Believable (-; : Awk rounding a float to integer got weird result: 123.12*100 -> 12312(good) but 1234.12*100 -> 123411(bad) [duplicate]
awk '{printf "%d\n", (1234.12*100)}' <<<""
outputs
123411
It is supposed to be 123412.
Awk version: GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)
What am I ...
0
votes
2
answers
88
views
Is it expected for sizeof(char) to return 1 instead of 4 when integer promotion takes place in C?
#include <stdio.h>
int main()
{
unsigned char c = 'a';
c = c + 3;
printf("%c ", c);
printf("%zu",sizeof(c));
return 0;
}
Output:d 1
when integer ...
-1
votes
0
answers
19
views
How can I correctly convert text to integer in SQLLite when inserting data from one table to another?
I need to populate one table with data from another in SQLLite. The problem is that the table where the data is being pulled from in one particular column (we'll call it ColumnA) is stored in Text ...
0
votes
0
answers
9
views
How can I use putchar to print numbers from 0 to 20 (or more)?
am looking on how to print digits for 0 to 20 and more with puchar
i tried using putchar('0' + 48) is just printing from 0 to 9, finding it hard to do that is there any help please, i have also tried ...
-1
votes
0
answers
18
views
error when converting string to float. It seems my datafame have mistakes [closed]
I have an error when converting string to float
This is my formula
Telco_churn["TotalCharges"]=Telco_churn["TotalCharges"].astype(float)
ValueError ...
-2
votes
1
answer
51
views
Extracting Raw Data from Integer and Long Variables in Java (Clarification Needed) [closed]
I'm working on a Java project where I have been tasked with extracting raw data from both integer and long variables.
However, I must admit that I am not exptert in java, so do not know the exact ...
-2
votes
1
answer
28
views
The Value Assigned to my Number In Public Static Int Method Doesn't Get Assigned [duplicate]
While I transformed parts of my code into methods, an integer I mean to increase under a certain condition (the player score) doesn't. This is a series of methods inside other methods inside a single ...
0
votes
0
answers
15
views
using google customsearch can you sort by metatag as a number
I am doing a Google customsearch function in an angularjs application calling search results using ajax
I can sort the data, but it is treating the metatag values I'm using as a string rather than the ...
1
vote
1
answer
26
views
element-specific array on array function
[TypeError: unsupported operand type(s) for -: 'list' and 'int']
I want to create a new array by calling on elements in array1 and array2. However, I want the elements I call on in array1 to ...
5
votes
3
answers
129
views
Is it required that either all or none of the C fixed-width integer types to be defined?
The specification specifies the types int8_t int16_t int32_t and int64_t (and their unsigned variants) and follows them with:
These types are optional.
In C the type char is at least 8 bits and ...
-3
votes
2
answers
95
views
Python: using loop for specific elements of array
I want to make a new array that has the original array's elements changed-- but I want to make the change different per elements in the original array like if the 3<=element is <6, take -1 from ...
0
votes
1
answer
48
views
Get instantaneous random number (in a loop) [duplicate]
I want to create fast new random number between 0 and 9. For this modified a code that I found there:
Why do I always get the same sequence of random numbers with rand()?
and integrated it into a loop
...
1
vote
1
answer
16
views
Phaser Number won't increase where I think it should
I have something of a minigame within a scene, that game is working fine, but I'm having trouble telling the rest of the code that its complete.
if (this.mini == true){
this.fixed = 4;
...
1
vote
1
answer
42
views
OpenGL 4.5 not writing integer renderbuffer
(OGL 4.5 on win10 with nVidia GPU).
I am trying to render labeled triangles as a single channel image with unsigned int pixels but apparently the frag shader is not writing to the framebuffer. I ...
0
votes
1
answer
24
views
No Instance Found on integer declaration greater than 7
I'm trying to model a problem that about some girls on the pool. There are some premises that must be followed.
Maiô: amarelo, azul, branco, verde
Nome: Ana, Bruna, Raquel, Vivian
Idade: 8, 9, 10, 11
...
0
votes
0
answers
35
views
Python - Regex matching not only what I want
I've made this Regex which should match positive and negative integers (3, -7), floats (-6.3, 3.14), scientific notations (-17e3, 10e-10, 53e7) and "incomplete" numbers (.1, -.7e+10):
([+-]?(...
-2
votes
2
answers
56
views
IF Statement is not returning a result. Android Studio in Java
to summarise this function pulls data from TextView value. It then converts it into a double then is supposed to perform an if statement which identifies which value is higher than the other.
Updated ...
-2
votes
0
answers
34
views
Python trying to convert to floating-point when it shouldn't
I have been writing my own emulated language recently, and have run into a problem with integers trying to convert to floating points.
To be clear, every number is referenced as an integer in this ...
0
votes
3
answers
45
views
(Python) How can I add a char into a string, if only there is a number behind it
How can I add '*' into a string, behind a specific char, if there is a number symbol after that char?
Here's my code that I tried, but doesn't work:
def timesAdd(string, char):
nString = None;
...
-2
votes
1
answer
64
views
How to reinterpret bits of float as int in python
I had to write code that printed out bits of floating point number (in hexadecimal). For C++, the first thing that came to mind was
std::cout << std::hex << *reinterpret_cast<uint32_t*&...
0
votes
3
answers
56
views
How to create quicksort for array of ints in C
I'm trying to design a function quicksort in C which sorts a array of ints in a decendent way.
I'm trying this code:
print_arr ista a function that prints all the elements of an array.
swap changes to ...
0
votes
1
answer
18
views
Understanding memset c
I'm trying to understand how memset works
Here is my implementation :
void *ft_memset(void *s, int c, size_t n)
{
size_t i;
i = 0;
while (i < n)
{
*((char *)(s + i)) = c;
...
-1
votes
0
answers
35
views
Unexpected size of arrays in C [duplicate]
int main()
{
int p[5];
for (int i = 0; i < 10; i++)
p[i] = i;
for (int i = 0; i < 10; i++)
printf("%d\n", p[i]);
}
I've set the size of array P to be only ...
0
votes
1
answer
23
views
Multiplying by 2 every other element in a list starting from the end of the list
I want to make a list that multiplies its elements by 2 starting from the end with a step of -2. For example:
a = [1, 2, 3, 4, 5, 6, 7]
# I want it to return a = [2, 2, 6, 4, 10, 6, 14]
I had some ...
0
votes
2
answers
47
views
C# changed specific value int and looping
i changed the question sample, i hope everyone understand what i meant.
i'm use .NET WinformApp
i want to make label1.Text gonna be show 1->2->3 and back to 1 again like repeat or looping from 1,...
-3
votes
3
answers
77
views
A beginner question about the return value of the C ternary operator
Consider this code:
#define SZIE 1024
printf("%\zu",SZIE<-1?1:0);
It will print '0'.
This confuses me.
In my view, the signed number -1 shoulkd be converted to SIZE_MAX.
The expression ...
2
votes
3
answers
93
views
Difference between & address and pointer address- Hexadecimal and pointer type data [duplicate]
I am using the following piece of code as a learning exercise for pointers:
int a=8;
int *ptr=&a;
printf("\nThe & address of a is: %x\n",&a);
printf("\nThe value of the ...
-1
votes
1
answer
57
views
Visual Studio Code terminal not working properly
The terminal won't output what I programmed. Before, I have written num = float(input("enter num")), and it would output a float. But after I changed it to an int, the terminal would still ...
-1
votes
1
answer
40
views
Python: How to check if adding/subtracting two 8 bit integers causes a carry or a borrow?
My question is as the title says: How to check if adding/subtracting two 8 bit integers causes a carry or a borrow?
Thanks!
1
vote
1
answer
43
views
Maximum value for Julia integer types
Julia Integer types have a minimum and maximum value.
When calculations go beyond those boundaries, results are 'incorrect'.
for i in Int8[5, 10, 15, 20]
println(i, " -> ", i^2)
end
...
-1
votes
0
answers
23
views
Merge char array to several integer values
Building a Remote control with two Adafruit feathers with RFM9x LoRa Modules. The sender module is connected to a throttle potentiometer and a Steering potentiometer, but gets parsed due to the LoRa....
0
votes
3
answers
57
views
Summation of distinct largest and second largest
I have trying to solve a problem in codechef on array of the summation of distinct largest and second largest. But it shows me error. I have tried but couldn't debug it yet. Would you help me, please?
...
-3
votes
4
answers
75
views
How do I tweak this program so it prints the largest negative integer?
The program below is supposed to print the largest integer entered by the user, but it only works for positive integers.
How can I make a small tweak so it works with negative integers and prints the ...
-2
votes
2
answers
53
views
Possible values of Integer.compare [closed]
In the documentation for Integer.compare(a,b) it says, that it will return a value below 0, if a is smaller than b, and a value above 0 if a is bigger than b.
After I have implemented the method in my ...
0
votes
0
answers
44
views
Value Change to some random value in the middle of the iteration
import java.util.*;
public class Main
{
public static int plusOne(int[] digits) {
int no =0;
for(int i=0; i< digits.length; i++){
if(digits[i]==0){
...
0
votes
2
answers
50
views
Error when generating results in cents (beecrowd - 1021)
The code is apparently working, but when inserting the value 576.73, the code fails to return the value in cents.
This is beecrowd exercise 1021.
#include <stdio.h>
#include <math.h>
int ...
0
votes
0
answers
14
views
The model item passed into the dictionary is of type System.Int32 [duplicate]
I am receiving this error message when trying to go to the "CreatePreparer" view.
I've tried converting the Ints to Int32 in the model, as well as converting the Ints in the reader to string....
0
votes
1
answer
78
views
Is sizeof(int) == sizeof(unsigned int) guaranteed by the standard?
Many programs assume sizeof(int)==sizeof(unsigned int) . IMO it is not and I cant find anything in the Standard which guarantees it. Am I right or wrong?
-1
votes
1
answer
55
views
Smallest Possible Integer
Smallest Possible Integer
Given an integer N, print the smallest possible integer that can be
formed using all the digits of N.
Boundary Condition: 1<= N <= 9999999999
Input Format: The first ...
0
votes
1
answer
30
views
Making a guessing game in C but outputs are different when I change variable types [duplicate]
I am new with C first of all. I was trying to write a guessing game. It is simple, you are just guessing until you find the number that program holds in "no_to_guess" variable. The problem ...
0
votes
1
answer
78
views
Fastest way to convert from unsigned integer + scale to double
As an input I have two parameters:
int64_t value
signed char scale
I need to get a double that's equal to value * 10^scale
would
static_cast<double>(value) * pow(10, scale)
be the best way to ...
0
votes
3
answers
78
views
Converting numpy array (or python list) to integer
I THINK BELOW QUESTION IS NOT POSSIBLE TO CALCULATE, SIMPLY BECAUSE 2^250 to BIG TO CALCULATE.
I have a numpy array, which has a shape of (1000,250) with binary values and I want to convert the whole ...