FAQ Database Discussion Community


How do I convert a string representation of an integer to a string in Java?

java,string,integer
I'm using a ContentResolver query to get some data from a database in Android. That's not the issue. The method returns string representation of integers, INT TYPE_MAIN = 2 I want to convert that to a string Type_Main String a = someMagicalMethod(TYPE_MAIN); System.out.println(a); Such that the output would be TYPE_MAIN...

Python typecasting string to int fails

python,integer,typeconverter
I get an error when I try to do a simple typecasting from string to integer in python (2.7): year = device.time[year_pos:].strip() # This is '1993' t = int(year) # Throws exception: "UnboundLocalError: local variable 'int' referenced before assignment" Why? :)...

Swapping integer array values in a for loop - Is it possible?

java,arrays,integer
So I decided to create a simple card deck shuffling program, nothing fancy just a single array with 52 "cards" numbered from 0 to 52. I'm not necessarily sure if it is the best method. I created a random integer method (randInt) to get random numbers and a shuffling method...

R: recursive function to give groups of consecutive numbers

r,if-statement,recursion,vector,integer
Given a sorted vector x: x <- c(1,2,4,6,7,10,11,12,15) I am trying to write a small function that will yield a similar sized vector y giving the last consecutive integer in order to group consecutive numbers. In my case it is (defining groups 2, 4, 7, 12 and 15): > y...

Making an array of random integers that add up to a certain number

arrays,algorithm,integer
I want to make an array of 7 integers, each of which is a random value between 2 and 5. That's easy, but I want to make it so the total sum of these integers must be 20. Any ideas?

Transform price with currency to single number if no numbers after comma

php,integer
I have a price, let's say $price = 9,00 €. If price have 2 zeroes after comma is there easy way to transform it to 9 € ? I mean is there a function for that or something. If that is not possible with € character, how to do that...

replacing numbers in a string with regex in javascript

javascript,html,regex,string,integer
I have string that contains numbers and characters. I want to replace the numbers with another value that will give it a css class of someClass. Now I got the code to detect all the numbers in the string and replace it with something else. My question is how do...

How do char and int work in C++

c++,char,integer,int
May be I'm going to ask a stupid question, but I want to confirm that how char works? Let me explain with examples what i want to ask. Let suppose I declare a char variable and then input 6 or any integer character. #include <iostream> using namespace std; int main(){...

post and pre increment not working as expected for REPL variable in scala

java,scala,compiler-errors,integer,post-increment
I know that there is no ++ and -- in scala instead I have to use += and -= But when I try scala> var a=2 a: Int = 2 scala> a +=1 scala> a res11: Int = 3 the above works fine but not the below one scala> 5...

Integer powers program Java help needed

java,integer
So i was getting this program in my book and tested it, it worked fine. I need help though understanding how it excactly works. I know the power of two means for example 2x2x2x2x2x2x2x2x2 = 512. Well, here is the program: // Compute integer powers of 2. class Power {...

In Smalltalk, how to select both strings and integers from an array

string,select,integer,smalltalk,pharo
Using Pharo, I have a collection e.g. array := #('up' '4' 'b'). and I'd like to use select: to create a collection that only includes the numbers, provided they're smaller than 20, and a specific string - in this case, 'up' and '4' I tried: array select: [:each | (each='up')...

Finding the maximum integer value contained in a matrix using Java

java,matrix,integer,max
I try to code some of this: /* * @param ints * @return the max value in the array of chars */ public static int maxMatrix(int [][] ints) { int max = ints[0][0]; for(int i = 0; i < ints.length; i++) { for(int j = 0; j < ints.length){ max...

0 randomly becomes 55?

objective-c,swift,integer,nsdictionary
I have an app in which I pass an dictionary of type [string:[int]] from a swift file to an objective c file, then as NSDictionary. Through that process, the data formats get all screwed up, but in the end I am able to access each array of ints from a...

Python code sum of integers between 10 and 20 [closed]

python,integer,sum
I need to write a python stand alone script that sums all integers (inclusive) between 10 and 20. I need to do this using a while loop and I am not sure how. This is what I have so far, the program is returning a sum of 0 not sure...

How does OpenGL resolve a multisampled FBO-attached color buffer whose pixel format is integer-based?

opengl,integer,fbo,multisampling
Suppose I format a renderbuffer like so: glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_R32UI, imageWidth, imageHeight); where sampleCount >= 2. And suppose I attach it to an FBO, draw some stuff into it, blit it to a non-multisampled FBO to resolve the multisampling, and finally call glReadPixels to get back some unsigned integers (one...

Simple python program - stuck

python,list,integer,range
I'm writing this code where it says if the person I put has a high score or not. It works fine when I put in a person within the list for example "Thor", however the program is not catching the error and not printing "no they don't have a top...

What is the best way to convert Dollars (Big Decimal) in Cents (Integer) in java?

java,integer,type-conversion,bigdecimal
I have to integrate my web application with a payment gateway. I want to input total amount in USD and then convert it into Cents as my payment gateway library accepts amount in Cents (of type Integer). I found that Big Decimal in java is best way for manipulation of...

Crystal Reports - Compounding Total in For Loop - Unexpected Results

loops,for-loop,crystal-reports,integer
I've been coding for 15 years, know many languages, C#, C++, PHP, PAWN, SMALL, ETC ETC. Crystal syntax is probably the most inconsistent and nonsensical I have ever seen. Anyhow, I am trying to do something simple here. I have a string formatted like this in my db: "1-DESC, 2-OTHER,...

cannot convert from int to byte [duplicate]

java,casting,integer,byte
This question already has an answer here: Is addition of byte converts to int is because of java language rules or because of jvm? 4 answers I have a rather simple - but for me confusing - question. Assume the byte variabels a,b,c: byte a = 5; byte b...

How Could I Convert A UITextField To An Integer In Swift 2.0?

ios,swift,integer
I'm a beginner at swift, and was doing some testing. To tell you the truth, I barely know what I'm doing yet, so please try to explain clearly. I was making a random number generator app & wanted to add in a uitextfield so that the user can type in...

Haskell length toInteger Conversion

haskell,integer,int,type-conversion,tuples
I have the following pair of Integers: maxCollatz :: (Integer, Integer) maxCollatz = (head $ maximum (map collatzList [1..500]), length $ maximum (map collatzList [1..500])) Since I am a newbie, I don't know how to use either fromIntegral or toInteger to convert length to Integer. I know that length must...

String replace with integer not working [closed]

java,string,replace,integer,replaceall
I have been working on some Java code and I came across a really weird error, Im trying to replace a piece of string with an Integer. Added all kinds of debugs but I cant seem to find it out. private void executeMsg() { value = value.replaceAll("(&([a-f0-9]))", "§$2"); String border...

NumberFormatException while converting a *binary* string to a number

java,binary,integer,number-formatting
So I have this binary string (32 chars corresponding to 32 bits): String s = "11111111110000011101110111011000"; When I try to convert it to a number, it throws a NumberFormatException: Integer.parseInt(s,2); Could not figure out why. Any idea? The strange thing is if I replace the first bit in the string...

how to write a function for numbers

c++,function,integer
Write a function that reads positive numbers from the user, and returns the largest number and outputs it. The function signature should be int largest(); So my question is, I'm not sure how to write function. Would I do something like an into main(); or is it something else?

C++ unsigned long doesn't wrap around after 4294967295

c++,visual-c++,integer,g++,long-integer
I was playing with some c++ code, and found that if I start a unsigned long with 4294967295 (its max allowed value) and add let's say 6 I MUST get 5, and it does! but the following operation of addition, and mod 255 does not give the correct answer. why...

Why do fixed-width integers print out chars instead of ints?

c++,integer,fixed-width
Given the following code. #include <cstdint> #include <iostream> #include <limits> int main() { int8_t x = 5; std::cout << x << '\n'; int y = 5; std::cout << y; std::cin.clear(); std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); std::cin.get(); return 0; } My output is a three-leaf clover and 5. If fixed-width integers are integers, why...

Python is returning false to “1”==“1”. Any ideas why?

python,string,file,integer,logic
I've written a scout system for my A Level computing task. The program is designed to store information on scouts at a scout hut, including badges, have a leaderboard system, and a management system for adding/finding/deleting scouts from the list. The scout information MUST be stored in a file. File...

Java integer to hex and to int

java,integer,hex,data-type-conversion
I have the problem, that the method does not work as expected. In most cases it works. However there is a case it does not work. I have a byte array containing some values. In hex e.g.: 0x04 0x42 (littleEndian). If I use the method convertTwoBytesToInt, I get a really...

evaluating localDate.now().minusDays(integer)

java,integer,evaluation
I've been working on a program that stores a series of scheduled events (home made ServiceRequest objects) in an xml file (f), and when I want to work with them I call a readData() method (see below) which loads the ServiceRequest's into serviceQueue(an ArrayList<ServiceRequest>) and I tag a null object...

Why is 1_2_3_4 a valid integer literal in java? [duplicate]

java,oop,inheritance,integer,literals
This question already has an answer here: Meaning of 0_0 in Java 7 [duplicate] 3 answers Wierd Syntax - Underscores between digits 1 answer Why does the following work? int a=1_2_3_4; System.out.println(a); // 1234 ...

Check if given number is Even, Odd or Neither in PHP? [duplicate]

php,floating-point,numbers,integer
This question already has an answer here: php test if number is odd or even 11 answers How can I get if a number is even or odd or neither (have decimal, like 1.5) with PHP? I know that there are operators like *, /, but they did not...

Converting a text entry(char) to an integer in java to be used in a java database

java,sql,database,netbeans,integer
I'm making a database system for a school project(Matric PAT) where I have to make a database in java (for this I'm using netbeans) and then I have to create a java program that connects to the data and is able to perform specific tasks like change data in the...

How to count a method within a method

ruby-on-rails,ruby,methods,model,integer
If we create a new method called days_left_in_current_level, what would we need to put in there so that we can count how many days are left in the current_level? habit.rb def current_level return 0 unless date_started def committed_wdays committed.map do |day| Date::ABBR_DAYNAMES.index(day.titleize) end end def n_days ((date_started.to_date)..Date.today).count do |date| committed_wdays.include?...

Mapping int to int (in Java)

java,algorithm,dictionary,integer,mapping
In Java. How can I map a set of numbers(integers for example) to another set of numbers? All the numbers are positive and all the numbers are unique in their own set. The first set of numbers can have any value, the second set of numbers represent indexes of an...

0 not an [int] in PowerShell?

powershell,integer,zero
My understanding is that (mathematically) 0 is an Int. And yet if (0 -as [int]){"Int"}else{"Not"} returns Not, at least for me in PS 2.0. Is this a bug in v2, or am I misunderstanding things? I have worked around the issue by testing for -as [int] -and -ne 0, but...

How to convert negative byte value to either short or integer?

java,integer,byte,short,typeconverter
We have a file which contains byte array in particular format like header and then followed by data. This file is generated by another java program and then we are reading that same file through another java program in the same format in which it was written. The program which...

How the type of the result is decided based on type of operand?

c,integer,unsigned
if we have int a = 1; unsigned int b = -1; what is the type of expression a + b; can i use int to store the result?...

Why can't I create an NSMutableArray of integers?

objective-c,arrays,integer,nsmutablearray
Is this format not allowed in Objective C? NSMutableArray arrayA=[0,1,2,3,4,5]; is the only way to do this by adding one integer at a time?...

Randomly iterate through sequence of integers, 1 to n [duplicate]

random,integer,sequence
This question already has an answer here: Generating non-repeating random numbers in Python 17 answers I have a range of integers I want to iterate through. You can assume the sequence begins with 1 and ends with n, where n > 1. However, I do not want to iterate...

How to read an integer input from the user in Rust 1.0?

input,integer,rust,user-input
The answers google returns are all based on from_str (including the one here: http://stackoverflow.com/a/25632307/8127), but apparently from_str(x) has changed into x.parse() in Rust 1.0. As a newbie, it's not obvious how the original solution should be adapted taking this change into account. So, as of Rust 1.0, what is the...

All possible chars for representing a number as a String, Integer.java

java,integer,hex
In Integer.java, there is the following piece of code: /** * All possible chars for representing a number as a String */ final static char[] digits = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' ,...

Integer validation method

c#,methods,integer
I have this question from a test paper that im having trouble with: Write the body of code for the method public static int enter_No_Of_Items(int min, int max) which will allow the user to enter a value for the number of items bought. The value should be validated in the...

Convert an ascii file column in integer

c++,perl,awk,grep,integer
I have a file with two columns, separated by space. The first column is integer but the second is double. My file has the following format 1 201.45 2 201.42 3 202.92 ... What I want to do is print the same file with two integer columns. The new file...

How to count current level missed_days?

ruby-on-rails,ruby,model-view-controller,methods,integer
How can we call something like this <%= habit.current_level.missed_days %> where we only call the missed_days from the current_level, instead of all the missed_days in a habit (to just give an general idea of what we want). For example if two boxes are checked, calling <%= habit.missed_days %> in the...

how to stop the program if the value i get for amount_notes is not an integer?

c,integer
Anyone know how to solve this problem? I want my program to be stop if the value of amount_notes is not an integer...But it still continue run although the value of amount_notes has decimal place or remainder... #include <stdio.h> #include <stdlib.h> #define acc_balance 5000.00 int main() { //variables decleration int...

Need to generate a random integer within a specified range

c++,random,integer
I need to generate a random integer within a user-defined range. It needs to use a single variable to store the result of the function invocation, and simply update the variable with each invocation. The function that uses the input to generate the random numbers: int genRandInt (int smallnum, int...

How to stop my do while loop from accepting every single string except “stop”

java,arrays,string,arraylist,integer
Write a main method that asks the user for an integer n which then allocates an array of ints of that size and stores that many integers as the user enters them. Once they are all entered, print them in the reverse order of how they were entered. This...

recognize palindromic sequences and count them on a given number

sql,numbers,integer
I have an integer input like this 1213121 I would like to count how many palindromic sequences are there (the ouput must be 5 palindromic sequences) Because the first palindromic sequence is 121. The second is 1213121. The third is 21312. The fourth is 131. The fifth is 121. I...

Setting Numeric Values to Card Values

java,arraylist,javafx,integer,character
here is what I have now: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.image.Image; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.stage.Stage; import javafx.scene.image.ImageView; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import...

Compression of Integers

algorithm,math,integer,compression
how can I compress a row of integers into something shorter? E.g. Input: '1 2 4 9 8 5 2 7 6 2 3 4' -> Algorithm -> Output: 'X Y Z' and can get it back the other way around? ('X Y Z' -> '1 2 4 9 8...

Change the width of a signed integer to a nonstandard width

c++,memory,integer,signed,signed-integer
For a networking application I need a signed, 2's complement integer. With a custom width. Specified at run time. Assuming the value of the integer falls in the width. The problem I have is the parity bit. Is there any way of avoid having to manually set the parity bit?...

Returning a List of Integers in Swift

python,list,swift,random,integer
I am an amateur Python programmer trying my hand at Apple's new Swift programming language. I recently decided to rewrite a Python script I have in Swift as a first step towards building this out into an iOS app. I ran into a bit of a challenge that so far...

C# remove item from list of integers int[] l = {1,2,3} - or use recursion to add them

c#,list,recursion,integer,sum
So there's this blog that gives Five programming problems every Software Engineer should be able to solve in less than 1 hour and I'm just revisiting some of the concepts. The first question reads Write three functions that compute the sum of the numbers in a given list using a...

Integer to custom type conversion in Ada

indexing,types,integer,type-conversion,ada
I have an array of some kind of objects, indexed by a type index: type index is new Integer range 1..50; type table is new Array(index) of expression; Now, I need to access one of these expressions, depending on a user entry by keyboard. For that I do following: c:...

PHP get integer from string [closed]

php,mysql,arrays,string,integer
I have a massive database storing customers' orders. I have to create a report (monthly and yearly) by total products sales and products brands sales. The main trouble is that in every order entry, I got a column called items, which stores ordered products info like: [32] (1 x 22...

Algorithm output to length starts new line

java,arrays,integer,string-formatting,system.out
I am trying to format the output from what I have written to display a list of primes (Eratosthenes) to a certain number results per line. Do they need to placed into an Array to accomplish this? I have not come across a way to implement their division besides .split("");,...

Java Integer out of range

java,integer
I'm learning Java and I'm trying little programs. I have a problem with this one: /* Compute the number of cubic inches in 1 cubic mile. */ class Inches { public static void main(String args[]) { int ci; int im; im = 5280 * 12; ci = im * im...

Converting factor to integer, duplicate [closed]

r,integer
I have a data frame and trying to convert the factor to integer levels for the purpose of assigning different values to integer columns and summing up. The data frame is below SYMBOL PVALUE1 PVALUE2 PVALUE3 1 <NA> 0 0 0 2 A1BG 0.570568468332992 0.638946096507843 0.500000024038353 3 A1BG-AS1 0.934667427815304 0.535423659692795...

What is the regex for “Any positive integer, excluding 0”

javascript,regex,integer
There is already an other post for this but i can't comment on it. Sorry for that. I used var pattern = new RegExp('^[1-9]\d*$'); var result = fieldValue.search(pattern); but i get a "-1" if I put 12 It allows me just number from 1 to 9 and no more. Is...

How can I parse fixed-length, non-delimited integers with attoparsec?

parsing,haskell,integer,attoparsec
I'm trying to parse two integers from 3 characters using attoparsec. A sample input might look something like this: 341 ... which I would like to parse into: Constructor 34 1 I have two solutions that work but which are somewhat clunky: stdK :: P.Parser Packet stdK = do P.char...

Matlab: Binary Linear Programming

matlab,matrix,binary,integer,mathematical-optimization
I am trying to solve some equations on Matlab using Binary Integer Programming. I have 3 sets of equations: Ma.X=1 Mp.X<=1 Mr.X<=m* Where, Ma is a known matrix with size 5*12 X is unknown set with size 12*1 Also Mp is known matrix with size 5*12 and Mr is a...

Pass data using Intent & bundle need to convert to int

android,android-intent,casting,integer,bundle
I'm trying to pass data to another activity, but after passing it I want to convert it to int is there a way to do that. This my code: Intent intent = getIntent(); Bundle bundle = intent.getExtras(); if(bundle != null) { checker.setText(bundle.getString("temperature")); String checkerHolder = checker.getText().toString(); int finder = Intent.parseIntent(checkerHolder);...

Round decimal for a float number

c++,visual-c++,integer,cocos2d-x-3.0
in VC++ I have a float number say 1.32544354353 i.e float num=1.32544354353; I want only first 1 digit after point. i.e 1.3 (not 1.300000000). How can I get this? Please help me... If their is a solution in Cocos2dx thats better(I want this in my cocos2d-x game)

Why doesn't the dart2js compiler convert 64-bit integers to IEEE 754 FP numbers?

javascript,integer,dart,precision
I've been reading that the dart2js compiler doesn't support 64 bit integers. Is this because javascript doesn't have a representation for 64-bit integers and stores all numbers as 64-bit double precision values? If so, couldn't integer values simply be converted to the representation? If that is not the case, why...

Pass Integer[] to AsyncTask - Android

android,android-asynctask,integer
I am having trouble passing an ArrayList to a class that extends AsyncTask. The AsyncTask class, DownLoaderTask, is created in the DownloaderTaskFragment class. The code for the DownloaderTaskFragment and DownLoaderTask are below. The MainActivity of this application passes the ArrayList to the fragment by setting Bundle arguments. In the code...

Can you append a string and a number as a single entry to a list in python?

python,string,list,integer,append
Is there a way in python 3 to append, to a list, both a string and a number as a single entry. For example if I had a list of class names, and wanted to be able to sort the list alphabetically, I would use: classNames = [] classNames.sort() print(classNames)...

Why did Java 8 introduce *Integer.sum(int a, int b)* [duplicate]

java,integer,java-8
This question already has an answer here: Purpose of Objects.isNull(…) / Objects.nonNull(…) 1 answer I just noticed that JDK8 introduced this method for Integer class: /** * Adds two integers together as per the + operator. * * @param a the first operand * @param b the second operand...

Filter out integers in an array of int and symbols

ruby,hash,integer,symbols
I've seen lots of post using .kind_of Integer or .integer? and these work if the input is an int or a string but I have a hash with values of symbols and integers and I want to iterate through the values and flag when I come across an integer. More...

Show price - double as Integer depending on its value in TextView - Android [duplicate]

android,textview,integer,double
This question already has an answer here: How to nicely format floating numbers to String without unnecessary decimal 0? 15 answers I would like to know how can I show in my TextView the price as follows: Price is a double value. a=8.75 and b=9.00 I need display a=8.75...

Convert part of string to integer

string,python-2.7,unicode,integer,type-conversion
I have two time values of type unicode and str like below: time1 = "10:00 AM" #type: str time2 = "10:15 AM" #type: unicode I want to convert integer part of time1 and time2 i.e 10:00 and 10:15 to integer and check if time2 > time1. Is there any way...

Python: Replace “wrong” floats by integers inside string

python,string,replace,floating-point,integer
I'm trying to replace all useless floats in a string (1.0, 2.0 etc.) by integers. So I'd turn a string like "15.0+abc-3" to "15+abc-3". Do you know a way to do that? I hope you understood my idea. If you didn't feel free to ask....

Convert SQL databound datatable cell to string with 2 decimal places, VB.net

sql,sql-server,vb.net,integer,decimal
I am currently working in Microsoft Visual Studio Express 2013 with a SQL Server back end. I am using a SQL query to pull a datatable and then selecting the first cell to pull a number from. I need to take this number from the datatable and then change a...

How do I get the absolute value of an integer without using Math.abs?

javascript,function,integer,absolute-value
How do I get the absolute value of a number without using math.abs? This is what I have so far: function absVal(integer) { var abs = integer * integer; return abs^2; } ...

Increasing numbers in strings by python or Tcl

python,arrays,string,integer,tcl
I have some strings with integer numbers (From 2 to 5 numbers in one string, separated by spaces) this is an example: 1 4 5 19 1 5 2 3 6 59 2 6 3 2 4 60 3 4 4 1 3 61 4 3 25 13 23 64...

Replace integers in a string using Visual Basic

vb.net,string,replace,integer
I am trying to replace integers in a string using Visual Basic and can't seem to get it just right. This is what I currently have: lblNewPassword.Text = txtOrigPassword.Text.Replace("[0-9]", "Z") I have also tried: lblNewPassword.Text = txtOrigPassword.Text.Replace("#", "Z") And: lblNewPassword.Text = txtOrigPassword.Text.Replace("*#*", "Z") ...

Why are shaders and programs stored as integers in OpenGL?

c++,opengl,opengl-es,integer,shader
I'm following the "OpenGL Superbible" book and I can't help but notice that when we create a shader and create the program that we attach the shaders to, we store them as GLuint which are unsigned integers. Why are they stored as numbers? What does the value of the number...

Combining columns of two csvs into one csv via Powershell

arrays,shell,powershell,csv,integer
Could do with somebodies guidance on this one, got a little bug that's driving me nuts and it would be great if somebody could point out what my problem is. I have two .csv (comma delimited) files, the first structured like this (but with more records): Name Count C:\users\user1\documents, .docx...

Weird error comparing ints [duplicate]

java,android,integer,int,compare
This question already has an answer here: Why does 128==128 return false but 127==127 return true in this code? 4 answers I have a weird weird weird weird error, first of all here the class which give me the error public class SpeciePesci { public static final SpeciePesce[] specie...

using string to break out of loop in java

java,string,integer
I simply would like to break out of a while true loop if the user enters in "STOP" into the scanner. Currently my scanner only takes in integers and I believe this is where the problem lies. If I try to type in "STOP" I get many errors saying "exception...

Find index of string + integer in python

python,integer,find
I have a string "Something M6" and I want to find if "M6" is present in the string or not. The 6 in "M6" can be any integer. Is there any way to find it without using a regular expression or a for loop

How can I use edittext value in for loop?

string,for-loop,android-edittext,integer
Even though I convert the value from string to Integer it throws an error as java.lang.NumberFormatException: Invalid int: "" ...

Python integer unexpected results [duplicate]

python,integer,ironpython
This question already has an answer here: Unexpected floating-point representations in Python 3 answers I am using IronPython 2.7 integrated into Rhinoceros 5 application. I am having a strange int() function result: import math angle = 45.0 tangent = math.tan(math.radians(angle)) n = 12*tangent print "angle: ", angle print "tangent:...

jQuery - Increase integer by using arrays content as the variable name

jquery,arrays,variables,integer
Okay. This might be a little bit difficult to explain. Let's just say I have three variables in JavaScript window.seconds = 0; window.minutes = 0; window.hours = 0; and also three anchor tags in HTML <a id='seconds_plus' href=''>Increase seconds</a><br> <a id='minutes_plus' href=''>Increase minutes</a><br> <a id='hours_plus' href=''>Increase hours</a><br> Each time a...

How to restart current_level for every third missed_day (3 strikes you're out!)?

ruby-on-rails,ruby,model-view-controller,checkbox,integer
For example if a user is on Level 4: Day 50, he is pushed back to Day 45. case n_days when 0..9 # Would go back to 0 1 when 10..24 # Back to 10 2 when 25..44 # Back to 25 3 when 45..69 # Back to 45...

TypeError when split converting string to integer

python,string,split,integer,type-conversion
I get to read a line from a file that contain certain set of numbers per line. My problem is that the input is from a string line and then I need to process it as integer, making the conversion as usually suggested. Although I check previous post on this...

how to make int values in R.java into String

android,eclipse,string,arraylist,integer
I am working on a project with a spinner and ArrayList and I want to use left to right language (Persian) this is my code: spinner1 = (Spinner) findViewById(R.id.spinnerVolume1); List<String> list1 = new ArrayList<String>(); list1.add("*****"); I want to use Persian words as ***** but eclipse doesnt let me. I tried...

adding pointer to integer in C

c,pointers,integer
In the following segment of code: if (buffer + strlen(buffer) >= len -1) beep(); note: len is an int, buffer is a pointer to char. I don't understand how would someone add buffer (a pointer) to the strlen() of a string and compare it to len. Can any one please...

[: : integer expression expected

bash,if-statement,integer
COUNTER=0 let COUNTER=COUNTER+1 count=`ssh -i /var/www/.ssh/id_rsa_root -o stricthostkeychecking=no $host $cmd` count1=`echo $count | awk '{print $4}'` printf "count1 : $count1\n" result1=${count1/.*} if [ "$result1" -ge "0" ]; then echo $host else echo $host exit fi If the value of $result1 is INTEGER and greater than zero, it'll goto IF loop...

Printing string as integers in python 3

python,string,integer
I'm writing a program in python 3 to convert input string to integers. There is just one problem with the code. That whenever a space comes it prints -64. I've tried editing a code but it prints -64 along with the space. Any advice? n = input("please enter the text:").lower()...

How do I convert string array element to an integer value?

android,string,integer
in my Android app I have a set of string array values - tvs[1], tvs[2], tvs3[3], etc., which contain the textview value from a number of Number Pickers. However, I need the Integer value of each of these strings, so I can then multiply this numeric value with the unit...

How to convert an ArrayList of byte[] to an array of Integer in Android?

java,android,arraylist,integer,bytearray
I'm trying to convert an ArrayList<byte[]> listByte to an Integer[] arrInteger. I'm getting the listByteof pictues from a server through an object. My goal is to get this Array of Integer(pictures) to later use it in a ListView(arrayAdapter = new MyClass(MyActivity.this, stringArr, arrInteger);. I tried like this: ArrayList<Integer> integerList =...

64bit integer in Javscript, from Mysql request

javascript,mysql,node.js,integer,64bit
I have this number 76561197993482001 (64bit int) stored as a bigint(20) in my database. But when I try to fetch it using : //node.js query('SELECT * FROM table',function(err,rows){ console.log(rows[0]["id"]);// I get 76561197993482000 }); I get the wrong number. I guess this is because js can't handle 64bit variables. I know...

How can I send a integer from my Java file to my XML folder? (Android Studio)

java,android,xml,integer,load
I have an int called playerCount in my MainActivity Java file and would like to import it to my XML file, How would I go about doing that? When I loaded an Java Method I wrote android:onClick="playSound" And then, public void playSound(View view) { MediaPlayer mediaPlayer = MediaPlayer.create(MainActivity.this, R.raw.sound); mediaPlayer.start();...

While loop through text file stops unexpectedly

c,file,while-loop,integer,fscanf
I am trying to loop through a text file that contains random content. It's current contents are: "13 -35 57 - 23723724 12taste-34the+56rain-bow845" My program should only get the numbers from the file (-35 as a negative number, but not - 23723724 due to the space in between) and no...

Can only concatenate list (not “str”) to list

list,python-2.7,for-loop,integer
I have written the following code snippet: origilist = [6, 252, 13, 10] decilist = list(xrange(256)) def yielding(decilist, origilist): half_origi = (len(origilist)/2) for n in decilist: yield origilist[:half_origi] + n + origilist[half_origi:] for item in yielding(decilist, origilist): print item when I run the code I get: yield origilist[:half_origi] + n...

How to distinguish same int and float elements?

python,list,floating-point,integer
I got following task: create a function that will receive as argument a list of different elements and return a list of original elements (count of each element in list should be not more than 1). Order of elements should remain. Like below: [1, 1.0, '1', -1, 1] # input...

Why am I receiving the error that I am multiplying by non-int type 'float'?

python,integer,numerical,runge-kutta
I am having problems with my code which is a Runge Kutta algorithm to numerically solve for a harmonic oscillator. Unfortunately, I am receiving an error that says I can't multiply sequence by non-int of type float. Considering this code is nearly verbatim from an educational text, I cannot see...

Roman Numeral to integer function

php,function,foreach,integer,roman-numerals
basically i am trying to create a function that will turn a Roman numeral into a integer. I have an array: $roman_numerals=[ 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX'...

Efficient comparison of small integer vectors

c,integer,compare,bit-manipulation,string-comparison
I have small vectors. Each of them is made of 10 integers which are between 0 and 15. This means that every element in a vector can be written using 4 bits. Hence I can concatenate my vector elements and store the whole vector in a single long type (in...

How to counter a java.lang.NumberFormatException in the following code? [closed]

java,string,integer,numberformatexception
I'm trying to find maximum XOR value. I'm converting the Strings p and q into the Integers n and m so I can check the exclusivity but I'm encountering a java.lang.NumberFormatException. How do I deal with that? import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution...