# Questions tagged [numbers]

4714 questions

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

1

votes

2

answer

32

Views

### Possible to auto fill code statements in android studio

I'm currently creating a soundboard app. I have about 100+ sound files to import.
I have code lines (android:onClick='song1') and (MediaPlayer mysound1).
Just wondering if there is a way to copy+paste these lines and have android studio auto change the line to 'song2' and 'song3' all the way to 'so...

1

votes

1

answer

104

Views

### Iterate over complex numbers

I need to iterate over the complex refractive index = n + ik
I made two floats.Span() filled with evenly spaced numbers, containing every n and k that I need to iterate over. How do I 'mix' these two values now so I can make a for loop over every possible combination?
I need something like:
0.1+0.1i...

1

votes

1

answer

130

Views

### Get language wise numbers using culture info in c#

I'm working on language wise numbers and I'm doing it via CultureInfo.
CultureInfo class provide Native digit for Arabic and Gujarati language but not for Hindi.
For example:
My number is in English: 123456
Same number in Gujarati language: ૧૨૩૪૫6 (This is working fine)
For English langua...

1

votes

0

answer

71

Views

### Error: Browser auto increments number in json response

I have an API, that returns a JSON object. One of the keys of the JSON object has the value of type 'array of integers'. The issue is browser increments the numbers in the array by 1 when receiving it from API.
Here is the API response received from browser and postman: THe one received from the po...

1

votes

0

answer

18

Views

### What is the best approach to pick range of numbers again and again from the range of numbers?

Let's suppose I have an array of 200 numbers from 1 to 200. If a user want to pick numbers from range 5 to 60 at a time. And next time, again if he wants to pick number from range next time, what is the best approach to check the numbers of range before used. Hit and trial is not best approach. How...

1

votes

2

answer

53

Views

### Calculating a number by experience point correlation

Looking at this RuneScape experience table: http://runescape.wikia.com/wiki/Experience/Table
You can see that an experience point amount correlates to a 'level'
where:
if (xp < 83){
level = 0;
}
else if (xp >= 83 && xp < 174){
level = 1;
}
//etc
So when I save just the experience as a field for my p...

1

votes

0

answer

46

Views

### Number addition within a range (overflowing)

Me again. That's right. Back at it with more rookie mistakes. Heh.
I was wondering if there was a way to do this, because I am having bad luck in my attempts and require assistance from someone more... able to problem solve than me.
I wish to have a function like this:
local function numberAddWithi...