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 "programming culture" explanation for why FF returns long fraction from measureText method?

All browsers except Firefox return a number without a fraction part from the Canvas element's measureText() method. FF returns values like 26.45682955697084. Since the measurement is said to be in pixels, I am wondering why the fraction in FF? …
blint
  • 191
  • 1
  • 9
3
votes
3 answers

Irrational number representation in computer

We can write a simple Rational Number class using two integers representing A/B with B != 0. If we want to represent an irrational number class (storing and computing), the first thing came to my mind is to use floating point, which means use IEEE…
CppLearner
  • 16,273
  • 32
  • 108
  • 163
3
votes
1 answer

How to get DecimalFormat to display ASCII strings instead of special symbols?

While playing around with double string formatting, I noticed that, at least on my locale, the strings produced by a default DecimalFormat object are different than the ones generated by Double.toString() when it comes to special cases like Infinity…
thkala
  • 84,049
  • 23
  • 157
  • 201
3
votes
3 answers

JavaScript Number preserve leading 0

I have a problem, I build a very simple javascript search for postal codes. I am using JS Numbers because I want to check if the passed number (search term) is less||equal or more||equal to the max and min. value >= splitZips[0] && value <=…
Lukas Oppermann
  • 2,918
  • 6
  • 47
  • 62
3
votes
2 answers

creating random numbers that favor smaller numbers

say i generated a set of random numbers and put them into an array, (pre-sorted for simplicity) i'll use javascript to show the math: var vals = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,...,10000); then in a loop, i created a random number…
kona
  • 139
  • 8
3
votes
4 answers

Sorting divs by number inside div tag and jQuery

I'm trying to sort a list of divs with jQuery. Essentially the list might look like this:
14
Robert E
  • 700
  • 3
  • 16
  • 29
3
votes
1 answer

How do I determine the maximum and minimum value for an Oracle NUMBER column?

Is there a simple formula for determining the maximum and minimum values for an Oracle NUMBER column with (p, s)?
Josh Kodroff
  • 27,301
  • 27
  • 95
  • 148
3
votes
1 answer

How do I convert a decimal number to REAL10 in MASM assembly?

Right now I convert the string containing the decimal number to an integer (ignoring the radix point for now), load it into ST(0), and divide by the correct power of ten to account for the radix point. This seems round about, and requires I have a…
wkf
  • 842
  • 9
  • 17
3
votes
4 answers

PHP - Generate number with leading zeros and starting from 100

I would like to have a function to generate numbers starting from "000100". Right now I have the following function that allows me to generate numbers with leading zeros. How can I modify it in order to fit my needs? function lz( $aNumber,…
Psyche
  • 8,513
  • 20
  • 70
  • 85
3
votes
3 answers

Android: display x^y

Some help please! How can i display raised numbers in a TextView for Android.For example if you want to display some Celsius degrees you can do this:textview.setText(number+"\u2103") and your good to go but i can't find a way to do something like…
Faur Ioan-Aurel
  • 791
  • 1
  • 7
  • 18
3
votes
3 answers

Implicit numeric type casting in C

Consider this simple code: int foo = 4; double d1 = sin (foo); double d2 = foo * 0.1; When i compile this with gcc, the results are as expected (i.e. mathematically correct), even though sin() expects a double as its argument. It appears gcc has…
idefixs
  • 712
  • 1
  • 4
  • 14
3
votes
3 answers

1: command not found

I'm writing a divides-by-three function in Bash, and it won't let me set a variable to a number. fizzy.sh: #!/usr/bin/env sh div3() { return `$1 % 3 -eq 0` } d=div3 1 echo $d Example: $ ./fizzy.sh ./fizzy.sh: line 7: 1: command not found
mcandre
  • 22,868
  • 20
  • 88
  • 147
3
votes
3 answers

Overflow/underflow in unsigned numbers

So, if you have a carry out of 1 on addition with unsigned numbers, you have overflowed, and if you have a carry out of 0 with subtraction, you have underflowed. Does this work in every case, though? If you do 5-0: 0101 -0000 = 0101 +(1111 +…
Risshuu
  • 101
  • 1
  • 3
  • 12
3
votes
1 answer

How to display a number with many decimal places? (Java)

I was wondering if there is a way to "cheat" and work with numbers with way more decimal places than a double in Java, and then display it via [Graphics Object].drawString(number, 10, 10); Can I do this?
Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80
3
votes
2 answers

MongoDB's NumberLong only 54 bit signed?

Is a MongoDB's NumberLong really 64 bit signed integer really 64 bit? MongoDB's NumberLong is said to be a 64 bit signed integer, which should mean we can play with -2^63 <= x <= 2^63-1, where x is a NumberLong. However, adding 1 or subtracting 1…
fsto
  • 63
  • 1
  • 7