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
92
votes
30 answers

Finding the length of an integer in C

I would like to know how I can find the length of an integer in C. For instance: 1 => 1 25 => 2 12512 => 5 0 => 1 and so on. How can I do this in C?
marabunta2048
  • 1,071
  • 1
  • 8
  • 9
83
votes
5 answers

JavaScript expression to generate a 5-digit number in every case

for my selenium tests I need an value provider to get a 5-digit number in every case. The problem with javascript is that the api of Math.random only supports the generation of an 0. starting float. So it has to be between 10000 and 99999. So it…
Christopher Klewes
  • 11,181
  • 18
  • 74
  • 102
78
votes
7 answers

Why was the space character not chosen for C++14 digit separators?

As of C++14, thanks to n3781 (which in itself does not answer this question) we may write code like the following: const int x = 1'234; // one thousand two hundred and thirty four The aim is to improve on code like this: const int y =…
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
61
votes
3 answers

How do get numbers to display as two digits in C?

For C programming. How do i get numbers to be displayed as 00, 01, 02, 03, instead of 0, 1, 2, 3. I just need 0 before the number until 10. i know when your doing decimals you can do "%.2f" etc. but what about in reverse for integers? here is what I…
Adeel Anwar
  • 729
  • 1
  • 5
  • 8
53
votes
5 answers

regular expression to match exactly 5 digits

testing= testing.match(/(\d{5})/g); I'm reading a full html into variable. From the variable, want to grab out all numbers with the pattern of exactly 5 digits. No need to care of whether before/after this digit having other type of words. Just…
i need help
  • 2,386
  • 10
  • 54
  • 72
31
votes
11 answers

C: how to break apart a multi digit number into separate variables?

Say I have a multi-digit integer in C. I want to break it up into single-digit integers. 123 would turn into 1, 2, and 3. How can I do this, especially if I don't know how many digits the integer has?
mugetsu
  • 4,228
  • 9
  • 50
  • 79
25
votes
5 answers

PHP equivalent of JavaScript's parseInt function?

Possible Duplicate: Check if a variable is a natural number Just came across where I need to sanitize an input and remove all non-digit characters with PHP. Thought of making a function myself, but just first wanted to check up on the possible…
Lucas
  • 16,930
  • 31
  • 110
  • 182
17
votes
1 answer

C/Objective-C read and get last digit of integer?

How can i get the last digit of an integer (or NSInteger) outputted to integer? example: int time = CFAbsoluteGetCurrent(); int lastDigit;
Daniel Node.js
  • 6,734
  • 9
  • 35
  • 57
17
votes
2 answers

Filtering out strings that only contains digits and/or punctuation - python

I need to filter out only strings that contains only digits and/or a fix set of punctuation. I've tried checking each character and then summing the Boolean conditions to check if it is equal to the len(str). Is there a more pythonic way to do…
alvas
  • 115,346
  • 109
  • 446
  • 738
16
votes
2 answers

What is the fastest algorithm for division of crazy large integers?

I need to divide numbers represented as digits in byte arrays with non standard amount of bytes. It maybe 5 bytes or 1 GB or more. Division should be done with numbers represented as byte arrays, without any conversions to numbers.
Kosmo零
  • 4,001
  • 9
  • 45
  • 88
15
votes
7 answers

VBA. How to find position of first digit in string

I have string "ololo123". I need get position of first digit - 1. How to set mask of search ?
Ololovin
  • 171
  • 1
  • 2
  • 4
12
votes
2 answers

Get last three digits of an integer

I wish to change an integer such as 23457689 to 689, 12457245 to 245 etc. I do not require the numbers to be rounded and do not wish to have to convert to String. Any ideas how this can be done in Python 2.7?
Luke Gatt
  • 169
  • 1
  • 2
  • 12
12
votes
8 answers

Algorithm for digit summing?

I'm searching for an algorithm for Digit summing. Let me outline the basic principle: Say you have a number: 18268. 1 + 8 + 2 + 6 + 8 = 25 2 + 5 = 7 And 7 is our final number. It's basically adding each number of the whole number until we get down…
Joe
  • 281
  • 1
  • 5
  • 8
12
votes
5 answers

Fastest method for adding/summing the individual digit components of a number

I saw a question on a math forum a while back where a person was discussing adding up the digits in a number over and over again until a single digit is achieved. (i.e. "362" would become "3+6+2" which would become "11"... then "11" would become…
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195
11
votes
3 answers

R, Knitr, Rnw, beautiful scientific numbers

I would like that all numbers generated by my knitr codes don´t look like an oldfashioned calculator. Is there any option to get the numbers like the last one (with ·10 instead of e or E) ? options(scipen=...) doesn't seem to have that…
skan
  • 7,423
  • 14
  • 59
  • 96
1
2 3
24 25