It seems like your toolchain has a 32-bit int type. The maximum value representable in such a type is 231-1, or 2,147,483,647. As you can see, that's a 10-digit number. You'll need to use a different type that supports larger numbers if you want to use this kind of an...

We can write the numbers you are looking for like this: re_n = (?:[^x]|^)\d\d\d(?:[^ip]|$) Then the whole expression is: ^(?!.*re_n.*re_n.*$).*(re_n) which basically eliminates double numbers using a negative lookahead following the line start anchor, then matches a valid number. The interpolated expression looks ugly: /^(?!.*(?:(?:[^x]|^)\d\d\d(?:[^ip]|$)).*(?:(?:[^x]|^)\d\d\d(?:[^ip]|$)).*$).*((?:(?:[^x]|^)\d\d\d(?:[^ip]|$)))/ This Perl code: my $re_n...

sed for printing lines starting with capital letters followed by digits. It also adds a - between them: sed -n 's/^\([A-Z]\+\)\([0-9]\+\) .*/\1-\2/p' input Gives: NUC-320 CJ-101 TECH-201 ...

You can use the decimal formatter for this as- NumberFormat formatter = new DecimalFormat("#0.00"); Log.d("formatted no is ",""+formatter.format(4.0)); Edit You can modify your code like this- public void onButtonClick(View v) after some formulas velocity2 = velocity * 0.00508; drop2 = pressuredrop * 249.174; vel.setText(formatter.format(velocity2)); dr.setText(formatter.format(drop2)); } ...

Your while condition is Math.Abs(n) > 1, but in the case of 10, you are only greater than 1 the first time. You could change this check to be >=1 and that should fix your problem. do { n = n / 10; i++; } while(Math.Abs(n) >= 1); ...

python,string,list,format,digits

Apply the same zfill function in a list comprehension, like this >>> [str(item).zfill(6) for item in data] ['000001', '000010', '000313', '004000', '051234', '123456'] Alternatively, you can use the string's format method, with format specifiers, like this >>> ["{:06d}".format(item) for item in data] ['000001', '000010', '000313', '004000', '051234', '123456'] If you...

#include <stdio.h> int main(void) { int i, n; for (n = 1; n < 1000000; n++) { for (i = n;;) { if (i / 10 % 10 > i % 10) break; if ((i /= 10) == 0) { printf("%d\n", n); break; } } } } 5004 numbers in...

string,powershell,split,wildcard,digits

Use a regex with a capture group: .*?S.*?(\d{2}).*?E.* > "some.text.S**01**E02.partofstring.mkv" -replace '.*?S.*?(\d{2}).*?E.*','$1' 01 > "some.textstring.S**01**E02.partofstring.mkv" -replace '.*?S.*?(\d{2}).*?E.*','$1' 01 ...

Your stopping condition is wrong: q%10!=0 will become "true" as soon as you reach the first zero in a decimal representation. For example, for a number 6540321 your program would add 32+22+12, and stop, because the next digit happens to be zero. Squares of 6, 5, and 4 would never...

c,constants,c-preprocessor,digits

You're missing quotes around the string. In C, a string is actually specified by a sequence of string literals. So you can do: #define DIGITS "10" printf( "%0" DIGITS "d\n", myvalue ); The preprocessor can also generate strings from other tokens (such as numbers). Check into the stringize operator (#),...

Convert to integer? static int GetDigit(int number, int k) { // k is the positiong of the digit I want to get from the number // I want to divide integer number to 10....0 (number of 0s is k) and then % 10 // to get the last digit of...

You can extract the numbers: String numberStr = yourStr.replaceAll("[^0-9]", ""); if you want to keep decimal point use: yourStr.replaceAll("[^\\.0123456789]",""); then you can check for individual numbers. To add space between numbers: String numberStr = yourStr.replaceAll("[^0-9]", " "); To get only the numbers, and store them to a string array: String...

c++,fstream,truncate,floating-point-precision,digits

The following works fine on my system (Win7, VS2012): #include <fstream> #include <iostream> int main (void) { std::ifstream file ("test.txt") ; long double d = 0 ; file >> d ; std::cout.precision (20) ; std::cout << d << "\n" ; return 0 ; } The text file: 2.7239385667867091 The output:...

python,sum,digits,sum-of-digits

Use integer division instead of floating point: x //= 10 ...

An awk: awk '/^[0-9]+\.[0-9]+/{printf "\n"}{printf $0}' filename For handling DOS line breaks: awk '{sub(/\r$/,"")}/^[0-9]+\.[0-9]+/{printf "\n"}{printf $0}' filename Demo: $ awk '{sub(/\r$/,"")}/^[0-9]+\.[0-9]+/{printf "\n"}{printf $0}' filename 0 15.239 23.917 Reprenem el debat que avui els oferim entorn de les perspectives d'aquest dos mil set. <ehh> Estavem parlant concretament dels temes 30.027 de...

java,string,digits,significant-digits

If in your current locale the decimal separator is a dot then you will get 0.920. If you want to get the result independent from you current locale to have as decimal separator a comma and as thousand separator a dot you could achieve it for example like this String...

Do both at the same time There is no need for a second check. Regex allows you to check both that the folder names contains natives, and that natives is followed by a dash and 14 digits, in a single pass. Use this regex: natives-\d{14} Or, if the 14 digits...

Have you tried: bool IsCorrectIP = ( ipstring.StartsWith("10.80.") ); Sorry if the answer is too terse. But that should resolve the issue at hand....

ios,objective-c,numbers,int,digits

There are probably better solutions, but this one is slightly shorter: int theNumber = 204398234; int theDigitPlace = 3;//hundreds place int theDigit = (theNumber/(int)(pow(10, theDigitPlace - 1))) % 10; In your case, it divides the number by 100 to get 2043982 and then "extracts" the last decimal digit with the...

c++,boost,standards,bit,digits

From this std::numeric_limits::digits reference: The value of std::numeric_limits::digits is the number of digits in base-radix that can be represented by the type T without change. For integer types, this is the number of bits not counting the sign bit. And later it states that for char the result is CHAR_BIT...

The best way I know is using forward-pipe operator %>% from magrittr package > library(magrittr) > mean(c(0.34333, 0.1728, 0.5789)) [1] 0.36501 > mean(c(0.34333, 0.1728, 0.5789)) %>% round(3) [1] 0.365 I should also mention, that package magrittr is used by another very popular package dplyr, which provides additional functionality for data...

Read the number, use an array of size 10 to count the occurrences, loop over the cyphers: int n; std::cin >> n; int occ[10] = { 0 }; while (n > 0) { const int c = n % 10; occ[c]++; n /= 10; } at the end, if occ[i]...

This should do the trick: def format(d: Double) = BigDecimal(d).scale match { case x if x > 2 => "%.3f".format(d) case _ => d.toInt.toString } ...

What's important to realize is that it's easy to take big steps: 1 digit numbers: 123456789 - 9 * 1 digit 2 digit numbers: 101112...9899 - 90 * 2 digits 3 digit numbers: 100101102...998999 - 900 * 3 digits 4 digit numbers: ... Now you can do a recursive solution...