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

long for 12 digit number?

I'm trying to use long for 12 digit number but it's saying "integer constant is too large for "long" type", and I tried it with C++ and Processing (similar to Java). What's happening and what should I use for it?
Hikari Iwasaki
  • 871
  • 2
  • 9
  • 11
2
votes
3 answers

Printing leading zeros in a number in C

I'm working on a project and I want my program to read a strictly 5 digits number with a leading zero. How can I print the number with the leading zero included? Plus: how can I provide that my program reads 5 digits including a zero as a leading…
user9994319
2
votes
1 answer

Determine if a number contains a digit for class assignment

Write a function named containsDigit that determines if a number contains a particular digit. The header should look like: bool containsDigit(int number, int digit); If number contains digit, then the function should return true. Otherwise, the…
coco
  • 103
  • 1
  • 1
  • 7
2
votes
2 answers

How can I manipulate specific digits of an integer value?

I have to create a control that can manipulate each "digit" of an integer value ( from 0 to 999,999 ). I know how to "Get" a digit of the integer - just Mod/Div - public class IntegerModel{ private int _value = 0; private int _GetValue( int…
Will
  • 3,413
  • 7
  • 50
  • 107
2
votes
3 answers

How to increment fixed significant digit in Java?

I am not sure that Java has tools for it but if there is a solution in Java it would be awesome. For example, I need to increment fifth significant digit in Double / Decimal / BigDecimal or similar variable. // Left is what I have. Right is what I…
Oleksandr
  • 3,574
  • 8
  • 41
  • 78
2
votes
1 answer

Three digits followed by dash after every two digits regex

My target is to add three digits followed by a dash on every two digits regex. Example: Given 01234342323 I need to obtain 012-34-34-23-23 I am using this regex: \B(?=(\d{3})+(?!\d)), but it did not work as expected. What should I change on it…
IntoTheDeep
  • 4,027
  • 15
  • 39
  • 84
2
votes
2 answers

Add all digits of a string in c++

I am trying to add all the digits of a string in c++, but it cannot passes all test cases. My code is given below. #include using namespace std; int main() { string str; long long int count=0; cin>>str; for(int…
2
votes
2 answers

How to limit digits before and after point in numberdecimal EditText

I have an app with single numberdecimal EditText. I want to filter digits before point from 1 to 120. And I want to allow user to input one digit after point. Example: User can input 1, 2.3, 23, 45.7, 89.6, 119.9, 120.0 etc. User can't input 3.34,…
2
votes
3 answers

Using regex to check if a string contains only one digit

I'm writing an algorithm and I need to check if a string contains only one digit (no more than one). Currently I have: if(current_Operation.matches("\\d")){ ... } Is there a better way to go about doing this? Thanks.
pmcg521
  • 349
  • 1
  • 4
  • 15
2
votes
4 answers

Regex comma separated single digits ordered ascending

I am attempting to write a regex to validate user input (asp.net, c#) which has the following conditions: - single digits within a range of 1 - 6 - comma separated, but list should not begin or end with a comma - digits cannot be repeated - digits…
Ant20
  • 87
  • 10
2
votes
2 answers

how to get all possible combinations of digits until 789?

Im trying to write algorithm to get all combinations and increment by one at a same time and get this function generate($index){ $xxx = ''; $flag = 0; $lengtchString = strlen($index); for($y = 0; $y != $lengtchString; $y++) { …
2
votes
2 answers

logical check of vector values at the same precesion or not

I have a vector with variable elements in it, and I want to check whether it's last two element are in the same digit order. For example, if the last two vectors are 0.0194 and 0.0198 return TRUE. because their digit order after zero is the same…
Alexander
  • 4,527
  • 5
  • 51
  • 98
2
votes
3 answers

Java String output

My String input is String Number = "546+90". I want to give output like this "546 + 90".how can i do it in java? Right now I am trying: Number.replaceAll("[0-9]"," "); But it doesn't seem to be working. Does anyone have any suggestions?
Asif Al Noman
  • 47
  • 1
  • 11
2
votes
1 answer

Problems clearing TextField when designed for digit-only input

I have a Java program used by my contributors and I need to update it to work on newer Windows versions. I had to decompile the existing one to get the code. One of the bugs is that one of the fields on the GUI is set up as a digit-only field, and…
ajrjaneway
  • 31
  • 3
2
votes
3 answers

Find target digit of an integer

What methods can I employ to return a specific digit of an integer? //val = number to find target digit on //dig = the digit to return from right-side private int digit(int val, int dig) { String num = "" + val; return…
gator
  • 3,465
  • 8
  • 36
  • 76