Questions tagged [digits]

Questions dealing with getting, manipulating, or changing the digits of numbers

Use this tag for questions dealing with getting, manipulating, or changing the digits of numbers. More about digits on wikipedia

1098 questions
2
votes
2 answers

Remove nth digit from an integer without converting to string

Say I have this integer in java, 987654321. I want to be able to remove, say the third and fourth digits, so I can get 9876521 in java. I know I can do this by converting to a string, then taking a substring, but is there a way to do this without…
jeffkmeng
  • 851
  • 1
  • 8
  • 30
2
votes
3 answers

sed substitute whitespace for dash only between specific character patterns

I have a lines like these: ORIGINAL sometext1 sometext2 word:A12 B34 C56 sometext3 sometext4 sometext5 sometext6 word:A123 B45 C67 sometext7 sometext8 sometext9 sometext10 anotherword:(someword1 someword2 someword3) sometext11…
Char
  • 105
  • 11
2
votes
7 answers

Swap digits in a double in C

What I want to do in C is swap two digits in a double. For example, if the input is 54321.987 and I want to swap the 2nd with the 4th digit, the output should be 52341.987. Example when too small: 12.34 would output 1002.34.
2
votes
1 answer

Regex to replace everything except trailing digits

This should be pretty straight-forward, but I'm unable to find the answer nor come up with it. I have a String which always has one or more trailing digits, and potentially other digits elsewhere. I want to remove everything from the string except…
Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135
2
votes
2 answers

Perl: replace consecutive digits with their count

My first questions here. I have a string of digits like 55111233 as you can see 5 is consecutive twice, 1 thrice 2 once and 3 twice. I want it to be replaced into 52132132 in general number1number2...numbern Please guide me.
user555615
  • 27
  • 4
2
votes
2 answers

"Can't convert 'int' object to str implicitly" error (Python)

I am trying to test if the decimal representation of a certain number contains the digit 9 at least twice, so I decided to do something like that: i=98759102 string=str(i) if '9' in string.replace(9, '', 1): print("y") else: print("n") But Python…
mxian
  • 139
  • 4
2
votes
2 answers

How to convert english "abc123 " digits to arabic "ابث١٢٣ " dynamically android

UPDATED i have been looking for solution but couldnt found it yet .. i have tried this // Check for language String tempLang = Locale.getDefault().getLanguage(); if (tempLang == "ar") { Locale AR_LOCALE_EAST_NUMBERS = new…
Atif Afridi
  • 133
  • 1
  • 10
2
votes
4 answers

Search for 10 consecutive single digits

I have a lady at work who sends me phone numbers. They are sent in a messy manner. EVERY TIME. so I want to copy her entire message from Skype and have a batch file parse the saved .txt file, searching only for 10 consecutive digits. e.g she sends…
2
votes
4 answers

C++ count the number of digits of a double

i want to do what the title says like this: int number1; cin>>number1; num1len=log10(number1)+1; cout<<"num of digits is "<
Dchris
  • 2,867
  • 10
  • 42
  • 73
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
1 answer

TCPDF/PHP & Fonts: Uppercase Numbers (Descent numbers? Old style?)

I'm given a special font with numbers like that: As you can see on the 3 for example, some numbers descent below the baseline. What I like to achieve is, that these numbers don't go below the line and that it looks like this: In Word this can be…
datort
  • 71
  • 4
2
votes
2 answers

Return sum of a number (positive or negative)

I need to make a function that takes a number and returns sum of it's digits, if the number is negative the first digit should be considered negative when adding numbers, this is what I have: var arrx = []; var oper; var others = 0; function…
user7451361
2
votes
2 answers

Method for adding commas to digit string in Java

The assignment is to add comes after every three digits looking from right to left. So number 1000000 should be 1,000,000 etc. I have relatively good idea how to tackle this problem, but I have no idea why am I getting no output. Maybe I am making…
user6179055
2
votes
2 answers

Compute digit-sums in specific columns of a data frame

I'm trying to sum the digits of integers in the last 2 columns of my data frame. I have found a function that does the summing, but I think I may have an issue with applying the function - not sure? Dataframe a = c("a", "b", "c") b = c(1, 11, 2) c…
dsnOwhiskey
  • 141
  • 1
  • 12
2
votes
1 answer

How to convert digits in the DateTime to Unicode culture in C#

I have converted datetime value in unicode using following code - CultureInfo cultureMarathi = new CultureInfo("mr-IN"); nextCheckDate=nextCheckupDateTimePicker.Value.ToString("dddd, dd-MMM-yyyy", cultureMarathi); It converts my datetime to…
AshishAim
  • 121
  • 1
  • 6