Questions tagged [digit]

Anything related to numerical digits, i.e. the symbols used to write the representation of a number in a number system, such as decimal, hexadecimal, octal or binary systems.

Anything related to numerical digits, i.e. the symbols used to write the representation of a number in a number system, such as decimal, hexadecimal, octal or binary systems.

See Wikipedia page on numerical digits.

375 questions
11
votes
4 answers

bash get a regular expression number up to 2 digits

I simply need to know how to make a regex that accepts a number that has up to 2 digits All I have just now is ^[0-9]{2}$ Which would match a number with exactly 2 digits, but I don't know how to specify "match a number which has up to 2…
Bluz
  • 5,980
  • 11
  • 32
  • 40
10
votes
3 answers

python isdigit() function return true for non digit character u'\u2466'

I come across a strange problem dealing with python isdigit function. For example: >>> a = u'\u2466' >>> a.isdigit() Out[1]: True >>> a.isnumeric() Out[2]: True Why this character is a digit? Any way to make this return False instead,…
lxyu
  • 2,661
  • 5
  • 23
  • 29
9
votes
4 answers

De Bruijn algorithm binary digit count 64bits C#

Im using the "De Bruijn" Algorithm to discover the number of digits in binary that a big number (up to 64bits) has. For example: 1022 has 10 digits in binary. 130 has 8 digits in binary. I found that using a table lookup based on De Bruijn give me…
Ignacio Bustos
  • 1,415
  • 2
  • 17
  • 26
9
votes
7 answers

Remove digits from a number in Java

How do I remove the first digit of an integer? My input is an integer (for example i = 123456789). I then want to remove the first digit, so that i equals 23456789.
user3159331
  • 99
  • 1
  • 1
  • 2
8
votes
10 answers

Finding a Specific Digit of a Number

I'm trying to find the nth digit of an integer of an arbitrary length. I was going to convert the integer to a string and use the character at index n... char Digit = itoa(Number).at(n); ...But then I realized the itoa function isn't standard. Is…
Maxpm
  • 24,113
  • 33
  • 111
  • 170
7
votes
2 answers

Formatting numerals and dates in other locales in C#/.NET

In an application I'm writing I want to display the current date and time, in English, but also in other locales. For example Russian, Arabic and Chinese. // DateTime.ToLongDateString doesn't support a IFormatProvider…
Amy
  • 154
  • 3
  • 9
7
votes
2 answers

Distinct digit count

Is is possible to count the distinct digits in a number in constant time O(1)? Suppose n=1519 output should be 3 as there are 3 distinct digits(1,5,9). I have done it in O(N) time but anyone knows how to find it in O(1) time?
Ronin
  • 2,027
  • 8
  • 32
  • 39
7
votes
7 answers

Digit grouping in C's printf

I wish to output large numbers with thousand-separators (commas or spaces) — basically the same as in How to display numeric in 3 digit grouping but using printf in C (GNU, 99). If printf does not support digit grouping natively, how can I achieve…
Gnubie
  • 2,587
  • 4
  • 25
  • 38
6
votes
9 answers

get the number of n digit in a 2+ digit number

For example, getting "5" in "256". The closest I've gotten is Math.floor(256/10)), but that'll still return the numbers in front. Is there any simple way to get what I want or would I have to make a big function for it? Also, for clarity: "n digit"…
Anonymous
  • 1,823
  • 7
  • 23
  • 29
6
votes
4 answers

How to use 12 digit number in C?

I am dealing with a math example. I need to use 12 digit number for my code. So which datatype should i use, to use the number in my functions?
DesperateCoders
  • 121
  • 1
  • 1
  • 9
6
votes
6 answers

How to get the rightmost digit from an Integer - Ruby

I am working on a program that requires me to read in and validate a number, but in doing so I need to take a two digit integer (for example we'll say 18) and add it 1 + 8. Now I have it working where I do a conditional check if it is greater than…
Zubatman
  • 1,235
  • 3
  • 17
  • 34
6
votes
4 answers

Most efficient way to get digit count of arbitrarily big number

What is the most efficient way to get the digits of a number? Lets begin with an example: Imagine the Fibonacci sequence. Now lets say we want to know which Fibonacci number is the first to have 1000 digits (in base 10 representation). Up to 308…
ThreeFx
  • 7,250
  • 1
  • 27
  • 51
5
votes
3 answers

Find & Replace digit by digit and space in Sublime Text

I have lot of digits and I want to add spaces in between them, like so: 0123456789 --> 0 1 2 3 4 5 6 7 8 9 I'm trying to do this using the search and replace function in Sublime Text. What I've tried so far is using \S to find all characters (there…
Zero
  • 1,864
  • 3
  • 21
  • 39
5
votes
2 answers

Digit Grouping in .NET

How do we input digit grouping in C#? My code works but only for one instance. I have to constantly click it to group every number in the calculator. How do we do group it so that if we click it, it groups every number (not only the number…
5
votes
6 answers

Prolog converting integer to a list of digit

I want to write a predicate that an integer and a list of digits, and succeed if Digits contain the digits of the integer in the proper order, i.e: ?-digit_lists( Num, [1,2,3,4] ). [Num == 1234]. Here is what I have so far: my_digits( 0, []…
Duc Hai
  • 51
  • 1
  • 3
1
2
3
24 25