numbers

Checking if an int is prime more efficiently

I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of our league so we settled on this one (and I am paraphrasing somewhat): "given an input integer n return the next int that is prime and its reverse is also prime for e...

Allow number to start with ZERO when stored in mysql integer field

I need to store phone numbers starting with 0 but whenever i try to store this in MySql table the starting ZERO is removed because no number start with Zero actually how i can solve this problem please do i need to change the field type from Integer to another type please help ...

Linux command line script to renumber files backward

I have JPG files numbered 3006-3057 that I would like to reverse number. I would be content renaming them by adding a backwards number count to the beginning of the name: img_3006.jpg > 99_img_3006.jpg and img_3057.jpg > 48_img_3057.jpg. ...

Regex : Matching phone numbers starting with NNN and having 10 numbers

I need to match phone numbers that : start with 010 or 012 or 016 or 019 Consist of 10 numbers exactly can you please help me on how to match numbers using PHP and regex thanks ...

sed: search and replace string with line number

Hi volks, I have a XML file with a lot of empty tag attributes. For instance: <mytag id=""> <ontent>aaa</content> </mytag> <mytag id=""> <ontent>bbb</content> </mytag> <mytag id=""> <ontent>ccc</content> </mytag> Now I want to replace id="" with e.g. id="2443" (id="[linenumber]") I tried to do this with sed, but I did not get ...

How to concatenate a number to a variable name in MATLAB?

I have a variable a = 1. I want to generate a variable name of the form: variableNumber so in this example, I would want a1 a2 a3 as variables. How can I do that? ...

No Secure Random Number Generators Available in JDK

Hi, I am currently running JDK 6 on Windows 7 and have installed the Unlimited Strength Policy Files. I wrote a Java app some time ago which used to work but now fails, giving an error message indicating that the SHA1PRNG SecureRandom is not available. I have tried printing a list of cryptographic providers available on the platform and ...

Is there a Perl module for parsing numbers, including ranges?

Is there a module, which does this for me? sample_input: 2, 5-7, 9, 3, 11-14 #!/usr/bin/env perl use warnings; use strict; use 5.012; sub aw_parse { my( $in, $max ) = @_; chomp $in; my @array = split ( /\s*,\s*/, $in ); my %zahlen; for ( @array ) { if ( /^\s*(\d+)\s*$/ ) { $zahlen{$1}++; } e...

Number representation problem in php

Hi everybody, It is a simple thing but i don't get answer for that. I am generated auto generation id concatenate with year 100001, 100002 like that, in this 10 is year 0001 is auto generation numbers. When i split the year and number then getting add one value is 2 for 0001. but i need as 0002. Adding value is 0001+1, 0002+1, 0010+...

Convert NSFileSystemSize to Gigabytes

I need to convert NSFileSystemSize to Gigabytes. NSDictionary * fsAttributes = [ [NSFileManager defaultManager] fileSystemAttributesAtPath:NSTemporaryDirectory()]; NSNumber *totalSize = [fsAttributes objectForKey:NSFileSystemSize]; NSString *sizeInGB = [NSString stringWithFormat:@"\n\n %3.2f GB",[totalSize floatValue] / 107374824...

Prime Numbers Code Help

Hello Everybody, I am suppose to "write a Java program that reads a positive integer n from standard input, then prints out the first n prime number." It's divided into 3 parts. 1st: This function will return true or false according to whether m is prime or composite. The array argument P will contain a sufficient number of primes to d...

Zend Lucene - cannot search numbers

Using Zend Lucene I cannot search numbers in description fields Added it like this: $doc->addField(Zend_Search_Lucene_Field::Text('description', $current_item['item_short_description'], 'utf-8')); Googling for this showed that applying following code should solve the problem, but it did not..: Zend_Search_Lucene_Analysis_Analyzer::s...

Teamcity - Build Number - Pass into ant script

I want to pass the build number from Teamcity into an ant script as a parameter. Does anyone know the exact syntax for doing this? ...

is it possible in javascript to create shortcuts with sequence like 123,345 instead of combo?

I already used some script to implement the shortcuts in my web page but i was wondering if could be possible to associate some combination not syncronic like Ctrl+X but more like a sequence typing 1..2..3 or any other combination to execute a script... lets assume this example: you have a long list with numbers: you could type 3..5....

check max characters in textbox

I have textboxes where i only want signed a max number of characters in. an then I'll hear how i could check it easily in c# ...

Common strategies to deal with rounding errors in currency-intensive soft?

What is your advice on: compensation of accumulated error in bulk math operations on collections of Money objects. How is this implemented in your production code for your locale? theory behind rounding in accountancy. any literature on topic. I currently read Fowler. He mentions Money type, it's typcal structure (int, long, BigDecim...

jQuery number seperator - Seperate number by each 1.000

Hi I'm developing a new site, and in here it's possible for the user to type in a price in a input-textfield. So what I need is some jQuery-code to transforn the typed in price. This means, that when a user types in "1000", the vissible text in the input field shall automatically be transformed to "1.000" - with a period. And if they ty...

What's the deal with char.GetNumericValue?

I was working on Project Euler 40, and was a bit bothered that there was no int.Parse(char). Not a big deal, but I did some asking around and someone suggested char.GetNumericValue. GetNumericValue seems like a very odd method to me: Takes in a char as a parameter and returns...a double? Returns -1.0 if the char is not '0' through '9...

Passing in number, Number.prototype.format

I've seen this format function referenced on several sites, but none of them have an explicit example of how to pass in a number into the function. I've tried '12345'.format('0.00') which I believe is how it should be written, but it gives me the error that the object doesn't support the property or method. I've also tried Number('1234...

Array construction and negative numbers

I was implementing a routing algorithm in javascript, but when I assign a negative one variable in the array gives me this error: invalid array length. var node = new Array() node[0] = new Array(6,7) node[1] = new Array(5,-4,8) node[2] = new Array(-2) //Here, invalid array length I do not know how to resolve this error. ...