Questions tagged [numbers]

A number is a mathematical object used to count, measure and label. Questions about using numbers in variables processing, numbers processing, conversion, display, logical numerical changes, data type existence, etc. For questions regarding phone numbers, please use tag [phone-number].

Different types of numbers are used in many cases. Numbers can be classified into sets, called number systems.

Natural numbers

The most familiar numbers are the natural numbers or counting numbers (1, 2, 3, ...). Zero is usually not considered a natural number, although definitions vary.

Integers

The integers are formed by the natural numbers (including 0) (0, 1, 2, 3, ...) together with the negatives of the non-zero natural numbers (−1, −2, −3, ...). Viewed as a subset of the real numbers, they are numbers that can be written without a fractional or decimal component, and fall within the set {..., −2, −1, 0, 1, 2, ...}.

Rational numbers

A rational number is a number that can be expressed as a fraction with an integer numerator and a non-zero natural number denominator. Fractions are written as two numbers, the numerator and the denominator, with a dividing bar between them.

A number is rational if (and only if) it can be written as a terminating and/or repeating decimal.

Real numbers

The real numbers include all of the measuring numbers. Real numbers are usually written using decimal numerals, in which a decimal point is placed to the right of the digit with place value one. Each digit to the right of the decimal point has a place value one-tenth of the place value of the digit to its left.

Complex numbers

The complex numbers consist of all numbers of the form

a + b*i

where a and b are real numbers and i is the square root of negative one (the imaginary unit).

More information on Wikipedia

12117 questions
3
votes
1 answer

is there a mathematical subset relation in java?

I want to express a mathematical subset relation in Java. In Mathematics we have nice relations like: the integers are a subset of the real numbers. I try to somehow express that in java with a Point class with generics: public class Point
3
votes
4 answers

Show more digits in PHP

Let's say I have: echo 1/3; And it print out only 0.33333333333333, can I get more digits?
Templar
  • 1,843
  • 7
  • 29
  • 42
3
votes
3 answers

Replace non-repeating binary values

I have a relatively straightforward dataframe, one column of which contains a sequence of binary numbers: 0 0 0 1 0 0 What I want to do is replace instances where 1 appears with 0: 0 0 0 0 0 0 But I want to apply this to cases where either 0 or 1…
nketchi
  • 39
  • 3
3
votes
1 answer

What's the best practice for working with numbers in DynamoDB (Python + boto3)

The Problem I know that DynamoDB is working with Decimals for every number it saves. I'm using python with boto3 and for every int I put in a table - it easily converts it to Decimal. The same isn't true for floats - when trying to put a float in a…
Shay Yzhakov
  • 975
  • 2
  • 13
  • 31
3
votes
1 answer

clang - poor rand() implementation

I had made a Pong game where I had to randomize the throw of the ball. To do this, I used the inbuilt random number generator and got good results in Ubuntu/GCC. On porting the code to Mac and compiling, the ball would only be projected in a single…
Aniruddha Deb
  • 272
  • 2
  • 7
3
votes
3 answers

Converting money formatted strings to floats

I have to read a rather large file, containing numbers, formatted in different ways. I have tried using the builtin floatval() function. This function works on some numbers, such as 22000.76, but not 22000,76. Reading the comments on php.net have…
Ragnar123
  • 5,174
  • 4
  • 24
  • 34
3
votes
1 answer

Odd number of elements in an array

When trying to figure out how to get the median value of an array, I first wanted to figure out if the number of elements in the array is odd or even. If the number is odd then the console will log the element in the middle. If there's an even…
user14320231
3
votes
6 answers

How to calculate the sum of a digits of a number in Scheme?

I want to calculate the sum of digits of a number in Scheme. It should work like this: >(sum-of-digits 123) 6 My idea is to transform the number 123 to string "123" and then transform it to a list '(1 2 3) and then use (apply + '(1 2 3)) to get…
bearzk
  • 685
  • 3
  • 7
  • 22
3
votes
5 answers

Why does age calculator work even when the input number is a string in Javascript?

In prompt the user's response is a string. Even if the response is a number, it comes back as a string. So I did some addition in the console: var numberOfCats = prompt("How many cats?"); var tooManyCats = numberOfCats + 1; If I type number 3 in…
3
votes
2 answers

Generate a 256 bit random number

I need to generate a 256 bits random unsigned number as a decimal string (with nearly zero probability of collision with anything generated earlier). How to do this in JavaScript (in a browser)?
porton
  • 5,214
  • 11
  • 47
  • 95
3
votes
3 answers

Order MultiIndex columns by string and number in pandas

I have a pandas multiIndex dataframe that I want to order by name and number. A similar dataset, df is created as example: random= np.random.rand(3,10) a = [ 'a','b','a','b','a','b','a','b','a', 'b'] b =…
Herwini
  • 371
  • 1
  • 19
3
votes
3 answers

How to write a binary literal in Dart

How do you write a Binary Literal in Dart? I can write a Hex Literal like so: Int Number = 0xc If I try the conventional way to write a Binary Literal: Int Number = 0b1100 I get an error. I've tried to look it up, but I've not been able to find…
maglax
  • 31
  • 1
  • 2
3
votes
4 answers

Removing nonnumerical data out of a number + SQL

I'm trying find the best way to remove nonnumerical data from a varchar in SQL e.g. '(082) 000-0000' to '0820000000' or '+2782 000 0000' to '0820000000' The difficulty is i'm not always sure what number formats are coming in, as shown above, so I'd…
Steven
3
votes
2 answers

.reduce returning concat instead of total sum

Can someone explain to me the differences between these examples please? Here's the original code. const items = [ { name: "Bike", price: 100 }, { name: "TV", price: 200 }, { name: "Album", price: 10 }, { name: "Book", price: 5 }, …
Jason
  • 47
  • 11
3
votes
1 answer

Comparing values in Custom Validator in Angular

I'm trying to compare two input values in a custom validator. There should be an error if the minValue is greater than the maxValue. FormGroup: sumFormGroup = this.formBuilder.group({ from: ['', [Validators.min(0), sumValidator]], to:…
pokly
  • 111
  • 2
  • 9
1 2 3
99
100