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

Mortgage calculator, how to exclude letter and accept only numbers

we have this method System.out.print("Enter Principal Amount (1k to 1m) ") ; while (true) { principal = scanner.nextInt(); if (principal >= 1000 && principal <= 1_000_000) break; …
sartep
  • 69
  • 4
3
votes
2 answers

How to generate non repeating random numbers in ios?

Possible Duplicate: Non repeating random numbers in Objective-C How to generate non repeating random numbers? I saw this on many sites but they give in main.c file code. When I use the main.c file the code working is fine, but when I try to…
Thukaram
  • 1,085
  • 2
  • 13
  • 33
3
votes
3 answers

Find largest possible number less than Y

Re-arrange the number X and find the greatest possible number that is less than or equal to Y. If that is not possible then return -1. Also, we should not have leading zeros for the generated output Example: X = 2851 Y =…
learner
  • 6,062
  • 14
  • 79
  • 139
3
votes
3 answers

Reversing a Number using bitwise shift

I am trying to find a way to reverse a number without Converting it to a string to find the length Reversing the string and parsing it back Running a separate loop to compute the Length i am currently doing it this way public static int…
Gautam
  • 7,868
  • 12
  • 64
  • 105
3
votes
4 answers

Return position of first number below 5 in values with decimal places

I would like to know the position of where the first number in a decimal place is less than 5. If this is not possible (where all numbers are 5 or over) then however many decimal places the number has should be returned instead. So this…
Chris
  • 1,197
  • 9
  • 28
3
votes
3 answers

How many of the numbers are consecutive in a string

Having this vector: vector <- c("236", "234", "", "12", "24", "3") [1] "236" "234" "" "12" "24" "3" I would like to check how many consecutive numbers there are in each element. Expected output: 2 3 0 2 0 0 I have no idea how to do this!
TarJae
  • 72,363
  • 6
  • 19
  • 66
3
votes
4 answers

Glob array by number value

I'm using glob to array my sub directories he orders them by the alphabet, i'd like to order them by numbers if i got sub-directories named 1 ,…
Elad
  • 75
  • 2
  • 10
3
votes
0 answers

how assign a number to output command in ruby

I want to list the networks from a airodump command and then assign a number for each network.Output of airodump is like this CH 1 ][ Elapsed: 24 s ][ 2022-06-22 11:12 BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH…
Damien
  • 31
  • 3
3
votes
1 answer

Why does Number constructor fail to parse numbers with separators?

Since JavaScript has numeric separators (_, U+005F), why does Number("3_0") return NaN? Shouldn't it work like Number("0x08") which returns 8? Number.isNaN(Number("3_0")) // true Number.isNaN(Number(3_0)) // false Number("3_0") === 30 //…
Wersjon
  • 33
  • 6
3
votes
5 answers

Java random number with high probability

I have an array char[] Select = {'A','B','C','D','E','F','G','H','I','J'} and each element in this array has different probability to be selected. For example, int[] Weight = {10,30,25,60,20,70,10,80,20,30}; My requirement is to select 5…
s77
  • 73
  • 1
  • 4
3
votes
2 answers

Convert string to number but maintain zeros in Javascript

I am working with GBP currency in Javascript and converting a string currency to a number like the following: Number('1.20') will give me 1.2. But I want to maintain the 0 when converting to a number type. Is this possible? This is the result that I…
Mohammed
  • 555
  • 1
  • 6
  • 19
3
votes
1 answer

Parsing using Polars

I am trying to load data into a polars DataFrame using the read_csv command but I keep getting this error RuntimeError: Any(ComputeError("Could not parse 0.5 as dtype Int64 at column 13.\n The total offset…
Rayen
  • 31
  • 1
  • 2
3
votes
1 answer

How is 65 bits number stored in 64 bits in JavaScript?

In the chapter "How Numbers Work" of the book "How JavaScript Works" by Douglas Crockford it is mentioned that a number in JavaScript is made up of 1 signed bit, 11 exponent bits, and 53 significant bits. This totals to 65 bits and some clever…
Darshna Rekha
  • 1,069
  • 7
  • 20
3
votes
1 answer

How to understand this number with "double scientific"-notation (~1e-9-4.999e-1) in matplotlib

I'm running a calculation that outputs a matplotlib plot with a vertical axis scaled with (see image below). ~1e-9-4.998e-1 This is very weird scaling and I'd like to make sure I understand the notation correctly. Does it mean the…
3
votes
1 answer

How to convert string into numbers in python

I see an interesting python exercise in codewars.it is about convert strings to numbers.I want some suggestions or guidance to solve this python exercise.Thank you this is the exercise:In this kata we want to convert a string into an integer. The…
M.HBA
  • 51
  • 6