Questions tagged [integer]

1

votes
1

answer
90

Views

Getting C# Int64 in Python

I have to get an Int64 object in Python. My code looks like this: from System import Int64 l = Int64.Parse('123') print(l, type(l)) but it returns: 123 When I did the same with DateTime c# object, it returned just right type: So why does Python convert an Int64 C# object back to it's own int clas...
Josef Kvita
1

votes
1

answer
63

Views

Getting from datatype string hexadecimal to INTEGER hexadecimal type in Python

I'm having an issue getting from hexadecimal string to hexadecimal integer in Python 3. When you write hex(12) you get the output 0xc which is a str class. However, when you type fx. int = 0x55 the class/type is an INTEGER. How do you go from '0x55' to 0x55 (as an integer) Thank you :)
Dapper
1

votes
1

answer
851

Views

Linear optimization with PuLP, additional condition on variables

I have to solve an integer linear optimization problem in Python with pulp. I solved the basic problem and now I have to add additional constraints. Is anybody who can help me with adding the condition with a logical indicator? The logical restriction is: B>5 if A>20 Here is my code: from pulp impo...
patii
1

votes
1

answer
19

Views

trasformation index array in value

example value return: array[1]=1 array[5]=5 array[12]=[1, 2] array[85]=[8, 5] array[7453]=[7, 4, 5, 3] array[8987556322415]=[8, 9, 8, 7, 5, 5, 6, 3, 2, 2, 4, 1, 5] Which is the best way to convert the index to an array with single decimal value (only one number for every index) var array=[30]; func...
ROth
1

votes
0

answer
22

Views

Non Repeating Random Integer values within range of previous guessed values

I am creating random number game for my class where the computer guesses random values within the range set by the user. I am trying to get it to the point where if the user input Higher or Lower, the new values will not disobey the previous values. For example, if the range is between 2-50 and the...
Blink
1

votes
0

answer
147

Views

How to solve a non-square linear system with integer solutions in R

Is there any way to solve a non-square linear system with integer solution in R? I want the elements of the vector-solution to be equal to 0 or positive. For example, I want to solve Ax=B with x∈c(0,1,2,3): A=matrix(c(1,-2,3,6,1,2,5,1,1,4,4,2),3,4,T) B=matrix(c(4,3,6),3,1,T) A [,1] [,2] [,3] [,4]...
Vassilis Chasiotis
1

votes
1

answer
31

Views

as.integer makes characters NA

I have some sequencing data for some biological samples. The file to read contains 7 columns first that contain characters, as they have gene names and codes etc. From the 8th column are my samples that contain count data, so a number assigned to a gene depending of how much of that gene is present...
user9317212
1

votes
0

answer
17

Views

How can keep these values in my list, they only execute when they're listed as strings, but then they have no value?

Cant return my 'suits' list in the random unless it is strings but i want to keep the values! Anything missing or any way I can force them later in my black jack game? import random import itertools Ace = 11 Jack = 10 Queen = 10 #trying to create an acurate point system held in these #variables...
Bruce Pouncey
1

votes
1

answer
884

Views

cvxopt.glpk.ilp documentation on Integer & Binary set keys

I have a mixed integer programming problem, (cutting stock with column generation), that I've solved in AMPL and I'm ported to Python using cvxopt. CVXOPT 'op' doesn't provide the binary variable option that I need, so I'm extending it with GLPK to use 'ILP'. I'm getting the ilp status = 'LP relax...
PointOnePA
1

votes
0

answer
46

Views

Find how many times an integer is in an array with varying integers [duplicate]

This question already has an answer here: Java count occurrence of each item in an array 16 answers find the frequency of elements in a java array 8 answers Frequency of elements in an array [duplicate] 4 answers Find the element with highest occurrences in an array [java] 8 answers I am trying...
Caleb
1

votes
3

answer
35

Views

Transforming month names to numbers

I have a userform that askes to which month the data input is applicable. I have used a combibox with jan, feb, mar etc as possible answers. Now I want to use these answers to refer to a sheet index number Jan is sheets(2), feb = sheets(3) etc. How do I do this? Private Sub Userform_Initialize() 'Em...
Boolean
1

votes
0

answer
78

Views

GAMS : Avoid Scan of obviously wrong solutions in CPLEX

I have the following problem in GAMS I implemented a location routing problem. While checking the .log file I noticed something that could speed up the calculation time immensly if I fixed it. Let me state an example first: Let's assume that we have a set S of all nodes consisting of s1*s140 nodes w...
Adam92
1

votes
1

answer
125

Views

How to implement uint32 addition and subtraction operations in Ruby?

Please do not suggest using any gems or creating classes for unsigned integers. Input data - strings that represent 4 byte sequence. Output data should be the same type of string. This is what I've got so far: def addition(augend, addend) sum = augend.to_i(16)+addend.to_i(16) sum -= 2**32 if sum >=...
MOPO3OB
1

votes
0

answer
128

Views

How to get intermediate Integer solutions when solving a MIP in Julia (JuMP)?

I am solving a MIP model using CPLEX in Julia. I know CPLEX has a so-called Solution Pool where all the intermediate integer solutions during the solving process are stored. Is there a way of accessing those solutions using Julia (JuMP)?
Berni
1

votes
1

answer
63

Views

Is an integer variable not numeric in Ruby?

I have user_waiting period saved as an integer in my DB. I am trying to use it in the below code, but I keep getting the error 'Expected Numeric.' I am very new to Ruby, and my understanding was that an integer would be numeric. Am I incorrect in this understanding? if @pto_management.waiting_period...
triepe
1

votes
1

answer
9

Views

Why isnt my module always printing the lowest of 3 single inputs?

I am trying to get it to print the lowest of the 3 inputs but it is sometimes printing the second lowest. a = (input()) b = (input()) c = (input()) if int(c) < int(b) and int(a): print (c) elif int(b) < int(c) and int(a): print(b) elif int(a) < int(b) and int(c): print (a)
ClintFromNYtoVA
1

votes
0

answer
31

Views

Pandas - dtype shows int, but describe shows float

I have changed my variable age to an integer since it was stored as a float: sessions['age'] = sessions['age'].astype(int) Pandas dtypes returns an int: In: sessions['age'].dtype Out: dtype('int64') However, describe() shows a float: In: sessions['age'].describe() Out: Name: age, dtype: float64 Tryi...
Lisadk
3

votes
1

answer
89

Views

X86 IDIV sign of remainder depends on sign of dividend for 8/-3 and -8/3?

Can anyone explain for me why the sign of the remainder is different in these cases? Is this an emulator bug or do real CPUs do this, too? 8 / -3 : quotient(AL) = -2 remainder(AH) = 2 -8 / 3 : quotient(AL) = -2 remainder(AH) = -2
user3018354
1

votes
1

answer
114

Views

Why is conversion not working?

I'd like to develop an algorithm that is able to do a AnyBase 2 AnyBase conversion in C++. So I started with just translating this javascript code into C++ and ended with the use of a BigInt - library because it will of course not work using integer (long int, long double, etc) precision - so I had...
1

votes
3

answer
91

Views

How to determine if an inputted integer contains certain digits without using strings

In this program I am supposed to figure out if the integer that the user enters contains a certain digit (in this case 7 and 3), and then return a boolean. So far I have: public static boolean contains(int num, int x) { Scanner input = new Scanner(System.in); int currentLength = numberDigits(num);...
UnknownJ25
1

votes
3

answer
43

Views

Print minimum integer of list's elements based on indices from other list

I have two lists a and b(both have same length) where the list b has only 1, 2 and 3 as its elements(random repetition allowed).Now , for all the indices of 1 in list 'b' I want to print a min integer from list a.And same for 2 and 3 in list 'b'. For example: a = [10,33,42,17,9,32,33,43,12,2,5,22] b...
gunjanpatait
1

votes
1

answer
30

Views

permutation for string doesnt work for array of ints

So I have the working string perm code below public static List myperm( String s ){ List l = new ArrayList(); mypermImpl('', s, l ); return l; } public static void mypermImpl( String built, String other, List l ){ if (other.length() == 0 ){ l.add( built ); } for ( int i=0; i
Joe Bloom
1

votes
0

answer
38

Views

Why does adding the integer 1 to another integer, then cast to a float give me .99?

I am in a visual programming class, trying to make a GUI in Processing that will eventually control an Arduino MeArm. I have a controlP5 element for each of the 4 servos, whose values are stored as int variables. For example, my variable for the elbow would be: eVal = (int)elbow.getValue(); I have s...
Janaga
1

votes
0

answer
62

Views

Avoiding integers multiplication overflow for 3+ integers

I'm testing my C++11 code with static analysis tool (CodeSonar). Here's my code: int weights_size = c * n * size * size; int weights_memory_size = weights_size * sizeof(float); if (IS_OVERFLOW_6(weights_memory_size, c, n, size, size, (int)sizeof(float))) { overflow_error(); } l.weights = (float*) ca...
frozenca
1

votes
2

answer
45

Views

How to group subarrays and perform conditional calculations?

I need to group my subarray using product_id and perform some conditional arithmetic. If moving_type is 1 then the overall product_number tally for the current product_id should be increased by the product_number. Alternatively, if the moving_type is 2 then the overall product_number tally should b...
Arka
1

votes
2

answer
103

Views

Calculate logarithm by hand

I'd like to calculate the mathematical logarithm 'by hand'... ... where stands for the logarithmBase and stands for the value. Some examples (See Log calculator): The base 2 logarithm of 10 is 3.3219280949 The base 5 logarithm of 15 is 1.6826061945 ... Hoever - I do not want to use a already imple...
jonas00
1

votes
2

answer
36

Views

'Split' integers in Terminal

In Ruby, I'm trying to solve a quiz as like a FizzBuzz Challenge. My question is 'How I can print the integer number |n| adding a comma and space(', ')at the end of they?' To separate the Namaand Team strings I'm using $stdout.print 'Team, ' && $stdout.print 'Nama, '. But for the integers my syntax...
gbs0
2

votes
1

answer
28

Views

How to convert an “unsigned” long to BigInteger

If we have a Java long value - say x - which should be interpreted as an unsigned value (i.e. 0x8000_0000_0000_0000 and higher should be interpreted as positive value) then how can I convert it to BigInteger? Obviously, BigInteger.valueOf(x) would result in a negative value, and conversion to hexade...
Maarten Bodewes
1

votes
0

answer
54

Views

How to add minimum up time constraint for a home load into a Mixed Integer Linear Programming in matlab?

I have written the code for the operation of the appliances for a minimum up time in a MILP problem in MATLAB. The code I have written is based on the lines of the 'optimal operation of thermal plants' tutorial video for MILP problem.Following is the link to it - https://in.mathworks.com/videos/mixe...
Paramvir Atwal
1

votes
0

answer
214

Views

Get marginal values (dual) for constraints in Pyomo MIP

I want to access dual variables for a MIP problem developed in python with Pyomo. To my understanding the dual is not created for MIP problems, but in my opinion there should be a work around for this. This should be possible to use as a minimal working example, I'm using Gurobi myself. I can see t...
maypay
1

votes
0

answer
590

Views

Count the number of Occurrences of each integer from user input using a single dimension array

I have to count how many times each number appears in an array. I have to have a specific out put which i have. Everything I have works correctly but I need the first loop at the 'break' to end without having to press 0. how can I get it to do this? Here is a copy of the code: package u07a1_numofo...
Quenten Guiles
1.5k

votes
22

answer
1.2m

Views
1

votes
1

answer
47

Views

Overflow Error #6 VBA while using long data type

New to VBA coming from Python so it is quit the difference. Sub Average_Income() Dim data As Worksheet Dim avg As Worksheet Dim i As Long Dim Total As Long Dim Bottom As Long Dim Low As Long Dim Mid As Long Dim Mid_High As Long Dim High As Long Dim Top As Long Dim Number As Long Set data = ActiveWo...
BDawg
1

votes
1

answer
217

Views

Use 64 bit integers in excel

Is there a way to force excel to use the integer format instead of double ? For example: A1: 122124841883276000 A2: 122124842368497000 A3: 485220992 =A2-A1 should be 485221000 Thanks!
ForeverLearning
1

votes
1

answer
12

Views

how to print specific content in json with php

I have a json print like this; https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi[email protected]example.com When i want to get result->26162616->pubdate i am getting error or null. my code : $source = file_get_contents('https://eutils.ncbi.nl...
Benjamin
1

votes
0

answer
22

Views

use string as regular text in code

the code reads a txt file with numbers divided as 537, 487, 1115, 652\n 1265, 395, 1629, 693\n the code reads the txt file and divides '\n' leaving a list like: ['537, 487, 1115, 652','1265,395,1629,693'] I need to use each string as a regular text in my code to crop an image using PIL so I'd like...
Thriskel
1

votes
0

answer
67

Views

How to hash integers within a for loop

I want to hash a range of integers. How can I define the argument in sha256 as we know it takes just string and buffer? c=list() import hashlib for i in range(0,10): d=hashlib.sha256(i).hexdigest() c.append(d) print(c)
1

votes
0

answer
114

Views

Solving system of linear equations with variables taking binary values

I am trying to solve a system of linear equations where the variables take binary values import numpy as np import numpy.linalg as LA import scipy.optimize as optimize A = np.array([[1/5, 1/2, 1/3], [1/4, 1/5, 1/6], [1/6, 2/9, 3/10]]) b = np.array([1, 1, 1]) x = LA.solve(A, b) My matrix A has around...
msksantosh
1

votes
1

answer
177

Views

Getting only integers when dividing a pandas dataframe by a pandas series

I am trying to divide a dataframe by a pandas series and the result is only giving ones everywhere. Here is the example : This is my dataframe df This is my pandas series s this is what I am getting result I am using pandas division. df.divide(s, axis=1). I tried to use as.type(float), it didnt chan...
Alaa J E
1

votes
0

answer
50

Views

Replacing modulus with multiplication

I would like to compute x % y (i.e. x mod y), where x, y are unsigned 64-bit integers and y is a constant. Is it true that it is possible to replace the modulus operation with some combination of multiplication, addition, shift and some well chosen constants? How to derive such sequence of arithment...
Ecir Hana

View additional questions