Questions tagged [numbers]

1

votes
5

answer
40

Views

Prevent pasting wrong values into Input number type

I have an Input element with type = "number", which is supposed to only accept 0,1,..,9 and "." Per default you can also wrie +, - ans soem other characters which I prevent with EventListener "keydown" and keyCodes. It works fine. But how can I prevent the user from pasting or drag and dropping some...
MichaelK
1

votes
2

answer
33

Views

How to check a condition on a list (or array) and then sort the elements based on that condition in Python

I have a list of complex numbers with n elements, I want to check that how many of the elements are real (the imaginary part is zero) and then sort my list in a way that it starts with the real numbers. For example for the list below: a = [ 7 + 0j, -2 + 3j, -2 - 3j, 5 + 6j, 5 - 6j, -1+ 0j, -8 + 4j,...
Amir Reza Jalali
0

votes
1

answer
22

Views

JQuery - Change integer to float with one decimal point

Eg. if I give 150 //output should be 15.0 If 1565 //output should be 156.5 Can anyone provide best code for the above logic?
Ejilarasan J
9

votes
11

answer
341

Views

How can I arrange numbers in this side-to-side pattern?

I am trying to make this pattern in PHP: 1 2 3 4 8 7 6 5 9 10 11 12 I tried this, but was unsuccessful: $num = 0; for ($i=0; $i
Smit Pipaliya
-3

votes
2

answer
25

Views

Random Number Generation in C# errors out

So i am trying to generate a random number and if the number is 3 or 8 i what something to happen , it this case to add 1 to one of the 2 integers keep in mind i really am only going off a book in C# and some knowledge in VB int Number1 = 0; int Number12 = 0; string text; string text2; Exexs: Rando...
Kernel
1

votes
2

answer
22

Views

Weird behaviour regarding python complex numbers

I'm currently writing a Mandelbrot program in python. In one implementation, I used python's complex number type. In the other, I implemented complex numbers as two separate numbers (I think I have an error there). I don't understand why the two programs output a different-looking result since they...
Ian Rehwinkel
14

votes
4

answer
659

Views

How can I update a table to insert decimal points at a fixed position in numbers?

I am using MS SQL Server 2014 and have a table with 3 columns and the field data type is Decimal(38,0). I want to update each row of my table to insert a decimal point after the first 2 digits. For example, I want 123456 to become 12.3456. The numbers are different lengths; some are 5 digits, some a...
Javad Abedi
1

votes
4

answer
168

Views

Create number for random and non repeat

i'm code: Random rand = new Random(); int[] arr = new int[4]; for (int i = 0; i < 4; i++) { for (int k = 0; k < 4; k++) { int rad = rand.Next(1, 5); if (arr[k] != rad) arr[i] = rad; } } for (int i = 0; i < 4; i++) MessageBox.Show(arr[i].ToString()); I wanna production numbers from 1 to 4 am and uneq...
Chavoshipor
1

votes
3

answer
984

Views

How to Use sendkeys when input type is number with Chrome

HTML PROTRACTOR TEST CODE let usern: ElementFinder = element.all(by.css('.text-input')).get(0); usern.sendKeys('error'); expect(usern.getAttribute("value")).toEqual("error"); browser.sleep(500); usern.clear(); browser.sleep(1000); usern.sendKeys('12345'); The element is found but no text is entered...
Mengxi Wang
-2

votes
0

answer
11

Views

Select numbers from text string

I want to create VBA code or function to select numbers from text string. In the string will be more numbers but I am looking only for numbers with 10 digits starts with 4 or 5. Result have to be shown in the separate column. Example of a string: Cell A1: KL 20x10 4500056879, 5600058789 NUT 58x45 5...
Lukas B.
1

votes
1

answer
466

Views

Check if NSString is valid number - whole or decimal number

I have an iOS app with a UITextField that allows the user to enter a number in. How can I ensure that the value the user types in is a valid number (either whole or decimal). Here is what I have tried, but for some reason it won't work for decimal numbers: NSCharacterSet *notDigits = [[NSCharacterSe...
Supertecnoboff
-1

votes
3

answer
18

Views

Find the difference to the closest higher number and the closest lower number in a list

I have a list of int and I want to find the difference to the closest lower number and the difference to the closest higher number from a given referenceNumber. So in this case, if the referenceNumber is 5 . How could it output closestLowerNumber = 1 and closestHigherNumber = 3 ? List Test = new...
Roblogic
1

votes
3

answer
43

Views

comparing two lists but then saying how many times an item in a list matched

I am trying to compare winning_numbers against the larger list of previous_winners then get the count of how many times a certain number turned up. winning_numbers = [20, 49, 47, 40, 36, 4, 2] previous_winners = [ [1, 8, 11, 25, 28, 4, 6], [13, 16, 34, 35, 45, 10, 12], [4, 5, 8, 31, 43, 2, 9], [2, 1...
mrpbennett
1

votes
3

answer
109

Views

Is that a number? C++ and via stringstream

I am a beginner in StackOverflow and in C++, this is my first post. The aim of this function is to get a line like: 1224435 1998-11-02 23:43:54 2514352842 00:01:22 01.25 callingNumber, dateOfCall, hourOfCall numberCalled durationOfTalk costOfTalk and then input it in the correct variables. The stri...
Mniek
0

votes
0

answer
13

Views

How to fix decryption formula to make whole number

What I mean is that my code works to a certain degree. The formula is correct until it reaches a certain level of encryption[the more combination to encryption key] // Simple array of chars where their index is the 'code' let lexicon = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C...
The Bomb Squad
1

votes
3

answer
552

Views

How to write a function to map points on a canvas to points on the real plane

I'm writing a simple Mandelbrot visualiser in Python onto a pygame Screen. For each pixel on the 600 by 600 Screen, I am plotting whether or not this pixel, (x, y) as a complex number, is in the Mandelbrot set or not. The problem being that I start at (0, 0) and iterate through to (600, 600), most o...
persepolis
1

votes
1

answer
585

Views

Separate Numbers and Letters

Let's say I have a String that says "Hello123", how can I separate them to become s[0] = "Hello", s[1] = "123"? I wish to use s.split() but I don't know what to put in the argument/parameter.
e-zard Yusof
1

votes
6

answer
441

Views

how to add two integers in a number

I am writing a credit card validation program. I am trying to see if a product is more that 1 digit long (i.e: 10), if it is I need to add the two integers together. For example 10 would be 1 + 0, which equals 1, how do I do this? This is what I have so far: public class CreditCard{ public static vo...
mdt
1

votes
2

answer
707

Views

Simple Python headache with number comparison

To keep a clean question, the problem is commented inside the code :) theOpenFile = open('text.txt', 'r') highest = 0 for myCurrentString in theOpenFile.readlines(): ## Simple string manipulation stringArray = myCurrentString.split() ## to get value, this seems to series = stringArray[0].split('.')[...
Geesh_SO
1

votes
2

answer
510

Views

split string based on number in sql server

In sql Server, I need to split a string based on number. What would be the best way for that. For example, I need to split below string I am looking for this query. 2. Can you please help. 3. I would really appreciate that. the result I am looking for is I am looking for this answer. Can you please...
user1943655
1

votes
2

answer
1k

Views

How to do jquery validation on something that is equal to zero, but not when its null/empty

So I want to validate a textbox that I have, the user can leave this box blank which is fine. However if they enter the number 0 in it, I want an error message to appear. However if it say is it null, it validates as an error when it is empty as well. I have done is it equal to "0" in quotes, how...
Ben
1

votes
3

answer
3.1k

Views

Parsing all the numbers from the file into BigDecimal Java

I would like to add all numbers from the input to the coollection and sort them. I have input file like that: 12i -+3456i 78,i910 11 i-12i 13.14r 15.r16r i17.18 -+19.20 +r21.22 +23.242526r +-27.28r -29.30r -.313233r r-0.343536rr r.34r 3536.r r+37.38 Liczba -0.1234 jest mniejsza niz liczba .2 i wiek...
1

votes
5

answer
1.2k

Views

Need to display price without decimal

Im trying to display price of a product, and when the price is a whole value to NOT display the decimal ".00"; But the current result is ALWAYS showing the decimal value. I have provided my current logic below; $price_value = "20.00"; //coming from DB as string if (is_int($price_value)) { //Display...
IEnumerable
1

votes
1

answer
735

Views

cause numbers to appear one after another when typing in textbox but also make them add up when 0 appears

Assignment Create a Windows application accepting integer numbers as input, one at a time, in a single field. A button Process causes displaying that number right below the input field, but only if it is larger than the currently displayed number (or it’s the first number processed). As soon as ze...
Pecheng Chang
1

votes
3

answer
670

Views

Find the nearest number of specific number which has specific digit (7)

Well, I have to write a program to find the NEAREST number of given number N which has exactly "K" 7s. For example, if input is: N K 1773 3 Output: 1777 Oh, one more thing is that N can be 100 000 000 000 000 maximum, will long long be enough to handle this? My code so far which is not working :( #i...
John Smith
1

votes
2

answer
266

Views

Wikipedia's line intersection formula can't handle large numbers?

I'm working on a little game that needed a function to calculate the point of intersection of two lines. So I got this formula off Wikipedia (http://en.wikipedia.org/wiki/Line-line_intersection) and made it into a function. bool lineline(int L1X1, int L1Y1, int L1X2, int L1Y2, int L2X1, int L2Y1, in...
bobismijnnaam
1

votes
2

answer
1.3k

Views

List of numbers in C# and getting min and max value without retaining variables stored in previous loop

So I have this thing that displays minimum and maximum numbers from a series of numbers inputed, please note I am just a beginner and haven't learned arrays or sorting yet: namespace ConsoleApplication12 { class Program { static void Main(string[] args) { double number, maxValue= Double.MinValue , m...
Sabotenderizer
1

votes
1

answer
845

Views

Operations with cuDoubleComplex inside cuda-kernel

I have a question to my implementation of a cuda kernel. I generated a cude kernel where i want to add elements of cuDoubleComplex Variables. Later on i also want to do some multiplication on elements. I tried several ways but could not find a solution. My function is: __global__ void process(doubl...
raspiede
1

votes
3

answer
1k

Views

small numbers java [duplicate]

This question already has an answer here: How to make the division of 2 ints produce a float instead of another int? 9 answers I am trying to divide two numbers in java - more specifically I have the fraction 800/9177 and want to convert it to a double or float or w/e. My problem is when I try to g...
user1090614
1

votes
5

answer
7k

Views

How to Generate random images through numbers c#?

I am making an app in which 4 chits are to be thrown randomly. I am done with generating random numbers by clicking on a button random numbers are generated between 1 to 4. My question is how do I associate the 4 images with those numbers? Suppose if 1 comes randomly - then 1.jpg should be display...
Adarsh Gumashta
1

votes
1

answer
681

Views

How to use isNaN here properly?

I have two fields. The first one is a name field and the other one is a number field. I want to check if the number field is numeric, if not, then select() will be used and background turns to yellow instead of blue. Somehow I'm not getting what I want. window.onload=function() { idUser = document....
Dora
1

votes
2

answer
218

Views

Status of cerf, cerfc, ctgamma and clgamma functions?

If we look to the draft of C11, the following names were reserved : 7.31 Future library directions The following names are grouped under individual headers for convenience. All external names described below are reserved no matter what headers are included by the program. 7.31.1 Complex arithmetic...
Vincent
1

votes
2

answer
1.1k

Views

Javascript math power real/irrational_number library [duplicate]

This question already has an answer here: JavaScript exponents 5 answers I was looking all around the web, but could not find anything that helps me. I need to do math: 10^(1.7), but javascript doesn't allow that. Can someone have sort of code or knows some library that could help me? Thanks in adv...
1

votes
2

answer
1.1k

Views

Complex numbers - Finding theta - C programming

I am a complete beginner at programming and Ive got a task to do, its pretty much just to find R and theta from a complex number, and take appropriate action using if statements depending which quadrant it is in. ie; when in quadrant 1&2 use calculated theta, when in quadrant 3 subtract 180degrees...
user2252867
1

votes
2

answer
1.3k

Views

Why is JExcel enforcing a cell's positive prefix ($) over the currency symbol assigned (£)?

I have an program that uses the JExcel library to read in excel sheets and do some processing on them. Once disturbing thing I've noticed (after being notified by one of our users) is that the JExcel seems to be force converting cells formated to be currency cells to use the $ symbol. I've done a lo...
Pureferret
1

votes
1

answer
112

Views

How to accurately convert numbers to strings in JavaScript

JavaScript stores all numbers in double-precision floating-point format, with a 52-bit mantissa and an 11-bit exponent (the IEEE 754 Standard for storing numeric values), and therefore its Number-to-String conversions are often inaccurate. For instance, 111111111*111111111===12345678987654321 is cor...
string QNA
1

votes
3

answer
580

Views

Multiplying numbers in a string at specific positions

I'm trying to solve the 8th Project Euler problem. Find the greatest product of five consecutive digits in the 1000-digit number. I'm pretty sure I'm way off. I also tried a simpler program using a while loop that returned 1 every time. The code that I have provided also returns 1 every time. Plea...
TGarr
1

votes
2

answer
95

Views

n number of 1s using binary operations

Is there any way to get n number of 1s using only these binary operations ( !, ~, &, ^, |, +, ) where n is an input? Example, n ---> output 0 ---> 0000 1 ---> 0001 2 ---> 0011 3 ---> 0111 4 ---> 1111 ...
sadaf2605
1

votes
2

answer
90

Views

How to check in java if 5<10>5<10 to n

How can I check for example from an array if 55 arr[j+1]) { System.out.println("ok!"); } } } For now I have this, but it's wrong.
user2417932
1

votes
1

answer
222

Views

Use NLP / Machine Learning to teach a machine how to detect if a string is mathematical?

I want to be able to detect if a string is mathematical. Strings that would evaluate to true on being mathematical would be "2", "42000", "-10", "-55.22", "forty-two", "fifty six", "negative ninety nine", and "negative one point seven". And since it is not numerical and mathematical something as com...
Django Johnson

View additional questions