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
6 answers

how to reverse only numbers in a string

INPUT : 123ABC458 OUTPUT : 321ABC854 public static void main(String []args){ String str="123ABC564"; int count=0; int ans=0; int firstindex=0; char[] ch = str.toCharArray(); for(int i=0;i
Bug
  • 137
  • 1
  • 11
3
votes
5 answers

Python program to add decimal point based on given value

The title might confuse you! Don't worry, I have explained it here: As an example, the convert() function should return 11.098 if I pass convert(11098,3). I am passing the convert(11098,2), so convert() should return 110.98. Here, any integer number…
3
votes
1 answer

In CMake, how do I check whether a string contains an integral number?

I have a string in CMake which I got somehow, in a variable MYVAR. I want to check whether that string is an integral number - possibly with whitespace. I have an ugly way to do it: string(REGEX MATCH "^[ \t\r\n]*[0-9]+[ \t\r\n]*$" MYVAR_PARSED…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
3
votes
3 answers

How to predict number sequences i.e. Excel?

In Excel, there is a nice feature where if you enter 1, 2, 3 in three consecutive cells and then select the cells and drag down, it automatically fills in the rest of the cells as 4, 5, 6, 7, etc. It is also able to match more patterns. For example,…
jasonbogd
  • 2,451
  • 4
  • 31
  • 42
3
votes
1 answer

How to write Numbers With Commas?

Sometimes in C++ I want to use large number like 1000000 and it's confusing. How can I use commas (if that is possible)? For example I want this to work int x = 1,000,000;
user16255957
3
votes
1 answer

How to convert very small, normal, Large, scientific number to string in php

I used this function but it does not work good with very large and small numbers function convert($number) { return (string)sprintf("%.40f", floatval($number)); } //example 1 // convert(10); //"10.0000000000000000000000000000000000000000"…
3
votes
3 answers

Add a zero before 1 digit number in a column pandas dataframe

I have a column in my pandas dataframe that includes communes of French cities. Here is an example: index Com 1 Paris 3 2 Paris 17 3 Marseille 5 4 Abainville 5 Aast 6 Marseille 15 7 Lyon 4 Except I would like to add a 0 to…
ascha
  • 103
  • 4
3
votes
3 answers

How to make 2 decimals place in javaScript

I need to show 2 decimals place after the total amount of payment. I have tried this way: cart.itemsPrice = cart.cartItems.reduce( (acc, item) => acc + (item.price * item.qty).toFixed(2), 0 ); then output show me like…
Alamin
  • 1,878
  • 1
  • 14
  • 34
3
votes
1 answer

How to find an integer multiplier to get to a power of 10?

I'm trying to create an exact decimal numeric type. I was storing it as a rational p/q where q is always as power of 10. Now if I try to divide one of these numbers, I need to see if the result is representable as a finite decimal expansion. For…
Rob N
  • 15,024
  • 17
  • 92
  • 165
3
votes
4 answers

How to control the number of decimals places for display purpose only using Image function in Ada?

I have the following code line in Ada, Put_Line ("Array of " & Integer'Image (iterations) & " is " & Long_Float'Image (sum) & " Time = " & Duration'Image(milliS) & timescale); The number of decimal places in sum is…
Aschoolar
  • 343
  • 3
  • 9
3
votes
1 answer

Data validation for numbers in Google Sheets not working

In Google Sheets, I set the data validation of a cell to a number that must be greater than or equal to 100. When I enter 9999999999999999999999, I get an error that the entered value must be greater than or equal to 100. Why does this happen? I…
user15389901
3
votes
2 answers

Why are integer variable sizes limited (to 32/64 bits, etc)?

Why are built-in Integer variable types (as well as some other numerical primitives) limited to 32 or 64 (rarely up to 128) bits in size, even in more modern languages such as Swift or Rust? I realize that in the olden days of severely limited…
Matt
  • 2,576
  • 6
  • 34
  • 52
3
votes
1 answer

How to calculate the winning chance of the lottery in c#?

using System; namespace FirstApplication { class Program { public static void Main() { int n = Convert.ToInt32(Console.ReadLine()); int k = Convert.ToInt32(Console.ReadLine()); string…
3
votes
2 answers

Rust error expected type `()` found type `(i32, i32)`

Pretty new to Rust, decided to brush up using the Advent of Code 2020 Day 1 Puzzle. I'm using the following function: fn find_numbers_2020(v: Vec) -> (i32,i32) { let mut n1: i32 = 0; let mut n2: i32 = 0; let mut cnt = 0; let…
3
votes
0 answers

Tesseract for negative numbers

What might I do to improve tesseract accuracy for negative numbers? For whatever reason it just won't detect it correctly, even though the picture is pixel-perfect. I'm running tesseract 4.1, using LSTM with fast tessdata. I've assigned…
Naltamer14
  • 187
  • 3
  • 10
1 2 3
99
100