# Questions tagged [numbers]

4721 questions

0

votes

1

answer

15

Views

### Space character before .toFixed method [duplicate]

This question already has an answer here:
Call methods on native Javascript types without wrapping with ()
5 answers
Strange syntax of Number methods in JavaScript
5 answers
Whitespace before dot (method call) allowed in Javascript?
3 answers
I noticed that if you put a space character before .to...

-2

votes

1

answer

24

Views

### How can I make an if-statement based on what has randomly been printed?

so I am creating a type of game that will involve dices. What I plan on doing is to have different things happening depending on what the player throws, it will be a 2 player game.
What I want to do is make the computer randomly generate 2 of the 6 possible dice sides. After that has been printed,...

1

votes

5

answer

98

Views

### How to get the length of every word in a string [duplicate]

This question already has an answer here:
How to get the length of words in a sentence?
4 answers
Hi this question needed to be deleted

1

votes

5

answer

32

Views

### Return Largest 3-Digit Chunk From String - JavaScript

I don't understand why this is returning zero:
function largestOfThree (num) {
let stringyNums = num.toString();
let highest = 0;
for (let i = 0; i highest) chunk = highest;
}
return highest;
}
console.log(largestOfThree(123456789));
It seems as though chunk is not getting assigned to highes...

1

votes

3

answer

2.4k

Views

### Why is a number having greater than 15 digits auto rounded in javascript? [duplicate]

This question already has an answer here:
Large numbers erroneously rounded in JavaScript
6 answers
I have a problem with javascript number. My problem is that I have a currency field in HTML and when I use javascript to calculate with another field; then if this input field has the number of digit...

0

votes

1

answer

18

Views

### I need help grouping data

i have got this far. when i run it, it turns the string numbers into floats and even gets rid of the time stamps for me. how then do i take these numbers and put them in new groups? what my goal is, is i want each line to be its own list but only the numbers between the time stamps and the last 0 of...

1

votes

2

answer

3.6k

Views

### How to know number is including specific digit without converting string?

For example i want to find numbers including 2,7 from 1 to 7000 without converting string.
2 7 12 17 ... 20 21 22 23...7000
Is there a good algorithm with math?
thank you in advance...

1

votes

0

answer

253

Views

### Sum of squares function in Python?

In Mathematica, there's a function called SquaresR that determines the number of summing k square integers to equal some specific natural number n:
http://mathworld.wolfram.com/SumofSquaresFunction.html
I have looked online for a Python package including a similar function and found nothing. Is ther...

1

votes

1

answer

73

Views

### C++ - Complex Value Calculation Error in Cross Spectral Density

I am a very beginner in c++ and I want to do some spectral calculations, in this case calculating the 'Cross Spectral Density' of two signal (vecFirst, vecSecond), which are already processed with a FastFourierTransformation. Resulting in freqvec and freqvec2, containing complex values for each freq...

1

votes

1

answer

133

Views

### How to print a random number with random method in constructor? [JAVA]

I want to use a method called printOneRandom to print a random number, but I am only allowed to create one single instance of Random in the constructor. (I need to create a similar method which uses Random again later) My code:
import java.util.Random;
public class RandomNumberHandler
{
public Rand...

1

votes

1

answer

78

Views

### Counting total occurence of comma-seperated positive and negative numbers in a string

I am trying to implement the algorithm for the counting the number of numbers in the string which contains positive integers,negative integers,positive floating numbers and negative floating point numbers respectively.
String is like this::
String mystring = '-7.5,-1.43,3.4,43.5, -9954.88, 949.5, 1,...

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...

1

votes

0

answer

27

Views

### tcrossprod for complex matrices

Suppose that A is a complex matrix and we want to calculate the product A%*%Conj(t(A)) as efficiently as possible. A%*%Conj(t(A)) is a Hermitian matrix so essentially we only need to calculate the elements on the diagonal and the elements below the diagonal because the elements above the diagonal ca...

1

votes

2

answer

31

Views

### jQuery only numbers and px/em input

I am trying that people can fill in pixels or ems in a inputfield but i want it a little nicer with a check / autofill.
Ths is the jQuery script what i now have:
$options.keydown(function (e) {
// Allow: backspace, delete, tab, escape, enter, dot, e, m , p, x
if ($.inArray(e.keyCode, [46, 8, 9, 27,...

1

votes

2

answer

26

Views

### Java - determine the position change of array

I have an understanding problem in my code but in a very specific row which is marked in the code below:
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
arrayTest();
}
public static void printArray(int [] a) {
for(int i= 0; i < a.length; i++) {
System...

1

votes

0

answer

67

Views

### Mathematical Approach to Converting a number to a currency

I am working on a project for my computer science course that is focusing on the C language, and I almost almost done, I just can't figure out why the currency convert function at the bottom drops some of the zeros in the numbers it prints. I am pretty new to C, and learning as I go, so I apologize...

0

votes

0

answer

14

Views

### How can I map a complex number to one or more qubits in Q#?

In short terms, I'm trying to implement in Q# the NonUniform Discrete Fourier Transform.
I've managed to do it bug-free in a classical manner(no quantum gates nor qubits used) yet the resource estimator says that no quantum resources used.
This makes me tend to believe that Q# in the back-end, even...

1

votes

0

answer

27

Views

### Format a number to a maximum width and variable precision

I would like to format a number (integer or float) to a string with the following requirements:
The total width must be n
The precision should be variable but minimal (between 0 and p)
Uses leading space if necessary
With n, a parameter given by the developer (me), and p the number of decimal exclud...

1

votes

0

answer

51

Views

### Get smaller decimal number from larger integer number

Sorry for a possible duplicate post, I saw many similar topics here but none was exactly I needed. My question is, suppose I have one large integer number,
int i = 1234567890;
I want to convert it into the decimal number with maximum 2 decimals, but the decimal number should fit into the range from...

1

votes

2

answer

402

Views

### Localized Ordinal Numbers in Java

Before you flag my question as a duplicate, I have already seen the answers to this question and this question. The ordinal suffix rules in English are simple enough as those answers demonstrate, but I'm hoping for an approach that supports localization. For example, the ordinal format of 10 is 10th...

1

votes

0

answer

214

Views

### How does we understand this float-point numbers (.1E0)

It is about data types in mysql and floating-point values, but I don't understand that format.
example: .1E0
I know E means *10
what does means the 0 there?
What number that represent?
another example:

1

votes

0

answer

48

Views

### ComplexImage to Matrix

I am working with the Accord framework.
I have transformed a few bitmaps into ComplexImage objects to perform 2D FFT on them(which is done). Now I would like to calculate the complex conjugates of these Fourier-transformed ComplexImagesobjects (for cross-correlation purposes).
I didn't find any tool...

1

votes

1

answer

47

Views

### Format Numbers with possible leading zeroes in PHP

I'm having a hard time to figure out, how to format a range of number correctly.
Lets say I have an array with the following values:
array( 1, 2, 001, 02, 012 );
How can I change the output of each value to fit the following format?
0 => 1
1 => 2
2 => 0.01
3 => 0.2
4 => 0.12
I'm not looking for a lo...

1

votes

2

answer

148

Views

### printing line number in c using getchar and putchar

is there a way to print out the line number in C while only using putchar and getchar and no arrays?
the output should look like this.
for example input mink
01: mink
02: jaguar
and so on
The line number should go from 01 to 50.
This is my start approach
#include
int main() {
int c;
int counter =...

1

votes

1

answer

57

Views

### Format number with PHP

I would like to format a number with PHP, but I do not get the desired result.
The number looks like this: 2.37405 and should be shaped so that it looks like this: 2.374,05.
My code looks like this:
echo number_format($new_price_formatted_no_discount - ($new_price_formatted_no_discount * 5 / 100), 2...

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...

1

votes

1

answer

63

Views

### Create list of numbers in Python from list-formatted string stored in file

I have a file that contains a list of numbers in a format exactly how Python would print it. It is a complex list and in the file it looks like this:
([(515.51, 615.76), (42.28, 152.3), (223.29, 138.07)], 1)
([(382.27, 502.27), (323.54, 473.01), (212.32, 433.57)], 2)
([(188.74, 442.8), (245.7, 461....

1

votes

1

answer

45

Views

### vbscript Get the line number after make ctrl+f in notepad

Well my question is: How can I get line number from notepad, I mean:
After make a 'ctrl+f ' and find my text I want to know in which line number is it.
Getting the text from status bar and store it in a string like 'Ln 18, Col 1'
It is possible?
Any ideas?

1

votes

0

answer

97

Views

### Visualizing complex function z1^n + z2^n = 1

I need to visualize this function z1^n + z2^n = 1 using Python and Mayavi. Parametrization for this function is as follows:
import numpy as np
import cmath as cm
from mayavi import mlab
e = np.e
pi = np.pi
n = 2
xi = 3
theta = np.mgrid[0:pi/2]
k1 = np.array([2,3])
k2 = np.array([0,1])
g = [0,1,2,3]...

1

votes

1

answer

40

Views

### convent a unsigned 32 bit integer to byte array which length is 4 byte and vice versa in java

a unsigned 32 bit integer,min is 0,max is The 32 square of 2 minus 1.I want to convent it to byte array which length is 4 byte and vice versa .
When I run the main method blow,everything is -1?I am so puzzled.
How to get the max from byte array and convent the max to byte array?And other number?
pu...

1

votes

1

answer

522

Views

### Numpy decimal points precision of complex numbers

Consider the following Python code which does some simple arithmetic operations over complex numbers in Python:
import numpy as np
s = 2
l = 5
v = np.array([np.exp(1j*2*np.pi/l)])
A = pow(s*v, l) + s*v
#Print the precision of np.complex128
print np.finfo(np.complex128).precision
#Export using 20 dec...

1

votes

1

answer

27

Views

### How to filter rows in pandas based on row numeric values

i have a dataframe like this:
mcnfecha mcnnumedoc mcncuenta
0 2015-12-31 1.0 14353605
96 2015-12-31 7.0 15400505
97 2015-12-31 7.0 15920505
98 2015-12-31 7.0 41351005
99 2015-12-31 7.0 41352150
100 2015-12-31 7...

1

votes

1

answer

51

Views

### LUA: Reading text after reading number does not work

I am struck with the io.read command in LUA. The example below jumps over the text-read line. That only happens if there is a number input before.
repeat
print('Input number!')
number=io.read('*n')
print('Would you like do to this again? (y/n)')
again = io.read()
until again == 'n'
I tried this in...

1

votes

1

answer

48

Views

### Comparing two numbers in sage

i would like to know why by comparing two real numbers (e.g. bool(r1 == r2)) in sage cas online it returns wrong boolean values.
E.g.§1:
(x,y,z)=var('x,y,z');
x=2
r1= (sin(x)).n()
r2= (sin(x)).n(digits=3)
print r1, type(r1)
print r2, type(r2)
bool(r1==r2)
0.909297426825682 ==
0.909
True
But E.g....

1

votes

2

answer

62

Views

### Add the consecutive digits of a birthdate recursively till it reaches to a single digit

I am developing a numerology application which has to provide a result which is similar to the following,
1 5 0 8 1 9 9 4
6 5 8 9 1 1 1
1 1 1 1 2 2
2 2 2 3 4
4 4 5 7
8 9 1
1 1
2
It has to add the consecutive digits and retain the first digit if the sum is of 2 digits.
I am missing something. Ad...

-2

votes

0

answer

18

Views

### How to create tier price amount according to value

I'm setting up a webshop to use in a printshop but I'm stuck on how to automatically provide prices for different amounts.
In example:
The client wants to see the price for 100 sheets and immediately it should see the price for 150, 200, 250, ... (it's cheaper per piece every time you the amount is...

1

votes

2

answer

29

Views

### Python: Generate ranged numbers and output the result to a file with a newline after each value appended

So what I am trying to do is to generate a list of number values arranging for example from 1 to 100000.
I have created a script that does that, but it only prints the output to the screen:
1
2
n
100000
What I need is exactly the same thing but appended to a file with a newline following each value:...

1

votes

0

answer

26

Views

### Countif date prior specific date

I've encountered problem and Im struggling with easy issue.
I want by VBA countif all items prior date.
I am sure that my code + excel file has dates formats, but it doesnt work.
When Im looking for exact date - it works, but when Im adding majority sign - VBA shows me always zero in prompt window....

1

votes

0

answer

64

Views

### Spring data solr, How to force numeric-looking string field to be solr string type

I'm trying to use spring-data-solr:3.0.6 to index data from different source, there is one field, casenumber having different format. When casenumber has ONLY digits, say 123, spring-data-solr will index the field as plong. That not causes problem until later on, a record with casenumber “CASE456...

1

votes

2

answer

35

Views

### Numbers triangle?

I am new to programming still trying to apply for an IT academy and learning the basics.
I am limited into using only arrays,strings,loops and conditions.
I have been given a task to print a triangle from 1 to N and below.
Example: 3
1
1 2
1 2 3
1 2
1
I used this:
var N = 2,
num = '';
for(var i=1...