Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 9/1194 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Java add leading zeros to a number....

    - by user69514
    I need to return a string in the form xxx-xxxx where xxx is a number and xxxx is another number, however when i have leading zeros they disappear. I'm trying number formatter, but it's not working. public String toString(){ NumberFormat nf3 = new DecimalFormat("#000"); NumberFormat nf4 = new DecimalFormat("#0000"); if( areaCode != 0) return nf3.format(areaCode) + "-" + nf3.format(exchangeCode) + "-" + nf4.format(number); else return exchangeCode + "-" + number; } } I figured it out: public String toString(){ NumberFormat nf3 = new DecimalFormat("000"); NumberFormat nf4 = new DecimalFormat("0000"); if( areaCode != 0) //myFormat.format(new Integer(someValue)); return nf3.format(new Integer(areaCode)) + "-" + nf3.format(new Integer(exchangeCode)) + "-" + nf4.format(new Integer(number)); else return nf3.format(new Integer(exchangeCode)) + "-" + nf4.format(new Integer(number)); }

    Read the article

  • Cheap Solution for Routing a Toll Free Number to a Standard POTS Number

    - by VxJasonxV
    I do some technical work for an Internet Radio Show/Podcast, and need to fix something that has been broken for a while. The hosts have a Skype-In number to take listener calls, and for convenience sake, I bought and paid for a toll free number for a period of time. I used to use Asterlink for routing calls, but they folded and sent my number to OneBox, but they're ridiculously expensive by comparison. I'm looking for a cheap solution for this one simple task. Forward toll free calls to a skype-in number. The definition of cheap is as cheap or cheaper than Asterlink was. I paid something like $2 a month, and then the termination/call rate, which was a fraction of a sent for termination, and only whole cents after some serious time on the call. A $20 preload lasted me months at a time. I don't want to be upsold too, I want a simple web based management screen (CDR/stats are fun!), and obviously, it needs to be reliable. What vendors out there are you a fan of that solves this need?

    Read the article

  • Cheap Solution for Routing a Toll Free Number to a Standard POTS Number

    - by VxJasonxV
    I do some technical work for an Internet Radio Show/Podcast, and need to fix something that has been broken for a while. The hosts have a Skype-In number to take listener calls, and for convenience sake, I bought and paid for a toll free number for a period of time. I used to use Asterlink for routing calls, but they folded and sent my number to OneBox, but they're ridiculously expensive by comparison. I'm looking for a cheap solution for this one simple task. Forward toll free calls to a skype-in number. The definition of cheap is as cheap or cheaper than Asterlink was. I paid something like $2 a month, and then the termination/call rate, which was a fraction of a sent for termination, and only whole cents after some serious time on the call. A $20 preload lasted me months at a time. I don't want to be upsold too, I want a simple web based management screen (CDR/stats are fun!), and obviously, it needs to be reliable. What vendors out there are you a fan of that solves this need?

    Read the article

  • number of args for stored procedure PLS00306

    - by Peter Kaleta
    Hi I have problem with calling for my procedure.Oracle scrams pls00306 Error: Wrong number of types of arguments in call to procedure. With my type declaration procedure has exact the same declaration like in header below. If I run it as separate prcedure it works , when i work in ODCI interface for exensible index creation , it throws pls 00306. MEMBER PROCEDURE FILL_TREE_LVL(target_column VARCHAR2, cur_lvl NUMBER, max_lvl NUMBER, parent_rect NUMBER,start_x NUMBER, start_y NUMBER,end_x NUMBER, end_y NUMBER) IS stmt VARCHAR2(2000); rect_id NUMBER; diff_x NUMBER; diff_y NUMBER; new_start_x NUMBER; new_end_x NUMBER; i NUMBER; j NUMBER; BEGIN {...} END FILL_TREE_LVL; STATIC FUNCTION ODCIINDEXCREATE (ia SYS.ODCIINDEXINFO, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER IS stmt VARCHAR2(2000); stmt2 VARCHAR2(2000); min_x NUMBER; max_x NUMBER; min_y NUMBER; max_y NUMBER; lvl NUMBER; rect_id NUMBER; pt_tab VARCHAR2(50); rect_tab VARCHAR2(50); cnum NUMBER; TYPE point_rect is RECORD( point_id NUMBER, rect_id NUMBER ); TYPE point_rect_tab IS TABLE OF point_rect; pr_table point_rect_tab; BEGIN {...} FILL_TREE_LVL('any string',0,lvl,min_x,min_y,max_x, max_y); {...} END;

    Read the article

  • Number of args for stored procedure PLS-00306

    - by Peter Kaleta
    Hi I have problem with calling for my procedure. Oracle scrams PLS-00306 Error: Wrong number of types of arguments in call to procedure. With my type declaration procedure has exact the same declaration like in header below. If I run it as separate procedure it works, when i work in ODCI interface for extensible index creation, it throws PLS-00306. MEMBER PROCEDURE FILL_TREE_LVL (target_column VARCHAR2, cur_lvl NUMBER, max_lvl NUMBER, parent_rect NUMBER,start_x NUMBER, start_y NUMBER, end_x NUMBER, end_y NUMBER) IS stmt VARCHAR2(2000); rect_id NUMBER; diff_x NUMBER; diff_y NUMBER; new_start_x NUMBER; new_end_x NUMBER; i NUMBER; j NUMBER; BEGIN {...} END FILL_TREE_LVL; STATIC FUNCTION ODCIINDEXCREATE (ia SYS.ODCIINDEXINFO, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER IS stmt VARCHAR2(2000); stmt2 VARCHAR2(2000); min_x NUMBER; max_x NUMBER; min_y NUMBER; max_y NUMBER; lvl NUMBER; rect_id NUMBER; pt_tab VARCHAR2(50); rect_tab VARCHAR2(50); cnum NUMBER; TYPE point_rect is RECORD( point_id NUMBER, rect_id NUMBER ); TYPE point_rect_tab IS TABLE OF point_rect; pr_table point_rect_tab; BEGIN {...} FILL_TREE_LVL('any string', 0, lvl,0, min_x, min_y, max_x, max_y); {...} END;

    Read the article

  • Help for creating a random String

    - by Max
    I need to create a random string which should be between the length of 6 to 10 but it sometimes generates only about the length of 3 to 5. Here's my code. Can anyone would be able to find out the problem? :( int lengthOfName = (int)(Math.random() * 4) + 6; String name = ""; /* randomly choosing a name*/ for (int j = 0; j <= lengthOfName; j++) { int freq = (int)(Math.random() * 100) + 1; if(freq <= 6){ name += "a"; }if(freq == 7 && freq == 8){ name += "b"; }if(freq >= 9 && freq <= 11){ name += "c"; }if(freq >= 12 && freq <= 15){ name += "d"; }if(freq >= 16 && freq <= 25){ name += "e"; }if(freq == 26 && freq == 27){ name += "f"; }if(freq == 28 && freq == 29){ name += "g"; }if(freq >= 30 && freq <= 33){ name += "h"; }if(freq >= 34 && freq <= 48){ name += "i"; }if(freq == 49 && freq == 50){ name += "j"; }if(freq >= 51 && freq <= 55){ name += "k"; }if(freq >= 56 && freq <= 60){ name += "l"; }if(freq == 61 && freq == 62){ name += "m"; }if(freq >= 63 && freq <= 70){ name += "n"; }if(freq >= 71 && freq <= 75){ name += "o"; }if(freq == 76 && freq == 77){ name += "p"; }if(freq == 78){ name += "q"; }if(freq >= 79 && freq <= 84){ name += "r"; }if(freq == 85 && freq == 86){ name += "s"; }if(freq == 87 && freq == 88){ name += "t"; }if(freq >= 89 && freq <= 93){ name += "u"; }if(freq == 94){ name += "v"; }if(freq == 95 && freq == 96){ name += "w"; }if(freq == 97){ name += "x"; }if(freq == 98 && freq == 99){ name += "y"; }if(freq == 100){ name += "z"; } }

    Read the article

  • javascript number split

    - by Jaron787
    Can anyboyd help me split up this date number in javascript so that when it is outputted to the screen it has slashes between the 4th and 5th number and the 6th and 7th number, so that it can be understood by a vxml voice browser. The number can be any value so i need it to work for any eight digit number. Like so: 20100820 2010/08/20 Many thanks

    Read the article

  • Is this a correct porting of java.util.Random in objectiveC

    - by dipu
    I have ported the code inside java.util.Random class in objectivec. I want to have an identical random number generator so that it synchs with the server app running on java. Now is this a safe porting and if not is there a way to mimic AtomicLong as it is found in java? Please see my code below. static long long multiplier = 0x5DEECE66DL; static long addend = 0xBL; static long long mask = (0x1000000000000001L << 48) - 1; -(void) initWithSeed:(long long) seed1 { [self setRandomSeed: 0L];// = new AtomicLong(0L); [self setSeed: seed1]; } -(int) next:(int)bits { long long oldseed, nextseed; long long seed1 = [self.randomSeed longLongValue]; //AtomicLong //do { oldseed = seed1; nextseed = (oldseed * multiplier + addend) & mask; //} while (!seed.compareAndSet(oldseed, nextseed)); [self setRandomSeed: [NSNumber numberWithLongLong:nextseed]]; ///int ret = (int)(nextseed >>> (48 - bits)); int ret = (unsigned int)(nextseed >> (48 - bits)); return ret; } -(void) setSeed:(long long) seed1 { seed1 = (seed1 ^ multiplier) & mask; [self setRandomSeed: [NSNumber numberWithLongLong:seed1]]; }

    Read the article

  • Smarty multiple random numbers list

    - by Heinrich
    Hey Stackoverflow-Folks, is there any smart way to post random numbers (e.g. 1-4) in a list by using the smarty tpl-engine? standart list sorted 1-5: <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> Here's my solution (PHP): <ul> {foreach from=randomNumbers} <li>{smarty.randomNumbers}</li> {/foreach} </ul> modified list sorted 1-5 (random): <ul> <li>3</li> <li>2</li> <li>5</li> <li>1</li> <li>4</li> </ul> I've really tested nearly everything, but I do only need a smart & small solution for this :-) Kind Regards, Heinrich

    Read the article

  • Random problem connecting to MySQL

    - by CharlesLeaf
    Environment: RHEL 5 servers, MySQL 5.1.43, PHP 5.1.6 (using MySQLi). Currently only available within our internal VPN network. Servers ServerA: Webserver ServerB/C/D: Database server (1 master 2 slaves) The error (on ServerA) [Tue May 25 11:12:17 2010] [error] [client CLIENTIP] PHP Warning: mysqli::real_connect() [function.mysqli-real-connect]: (HY000/2003): Can't connect to MySQL server on 'ServerB' (4) in /home/**/Database.php on line 67, referer: [website] Problem description It appears that at completely random times, our website is unable to connect to one of the MySQL servers - usually the Master. Except for the forementioned error message, there is nothing to be found in any of the logs as far as I can see, and most of the times the connection is succesful and everything works as it should. It's just at completely random times, this error pops up. There's no firewall blocking any internal traffic, timeout value is 3 but it doesn't take 3 seconds before it fails to connect. With the default mysql client I can connect from ServerA to ServerB,C and D and haven't encountered a problem yet. Does anyone have a clue what I might be overlooking / could be the problem? Because I've run out of ideas myself.

    Read the article

  • Random Movement in a Fixed Container

    - by James Barracca
    I'm looking to create something that can move randomly inside of a fixed div container. I love the way the object moves in this example that I found searching this website... http://jsfiddle.net/Xw29r/15/ The code on the jsfiddle contains the following: $(document).ready(function(){ animateDiv(); }); function makeNewPosition(){ // Get viewport dimensions (remove the dimension of the div) var h = $(window).height() - 50; var w = $(window).width() - 50; var nh = Math.floor(Math.random() * h); var nw = Math.floor(Math.random() * w); return [nh,nw]; } function animateDiv(){ var newq = makeNewPosition(); var oldq = $('.a').offset(); var speed = calcSpeed([oldq.top, oldq.left], newq); $('.a').animate({ top: newq[0], left: newq[1] }, speed, function(){ animateDiv(); }); }; function calcSpeed(prev, next) { var x = Math.abs(prev[1] - next[1]); var y = Math.abs(prev[0] - next[0]); var greatest = x > y ? x : y; var speedModifier = 0.1; var speed = Math.ceil(greatest/speedModifier); return speed; }? CSS: div.a { width: 50px; height:50px; background-color:red; position:fixed; }? However, I don't believe the code above constricts that object at all. I need my object to move randomly inside of a container that is let's say for now... 1200px in width and 500px in height. Can someone steer me in the right direction? I'm super new to coding so I'm having a hard time finding an answer on my own. Thanks so much! James

    Read the article

  • Trying to grab several random videos from database, but it just shows the same one all the time.

    - by Birk
    Hi guys, I'm trying to grab several random videos from my database, and have them show on a page. However, it just keeps on grabbing the same video rather than several different ones. So I end up with 5 of the same video rather than 5 different ones. Here's the grab random PHP code file... and after it is the template output file. //===================================================== // Random | Previous | Next //===================================================== $show['random'] = $db->quick_fetch( "SELECT file_id, title, title_seo, category_id, thumb FROM files WHERE files.category_id = '".$show['main']['category_id']."' AND files.verified=1 ORDER BY RAND() LIMIT 0,1; "); Here's the template CSS html thingy code I have this pasted 5 times to show 5 random videos <td valign="top" width="53%"><? $sql="select * from files ORDER BY rand() limit 0,5"; $res=@mysql_query($sql); $data=@mysql_result($res,0,'filename'); $id=@mysql_result($res,0,'file_id'); $title=@mysql_result($res,0,'title'); $title2=str_replace(" ", "-",$title); $path="{$siteurl}/media/{$file.random.file_id}/{$file.random.title_seo}/"; $img="{$siteurl}/thumbs/{$file.random.thumb}"; echo " {$file.random.title}"

    Read the article

  • Using a random string to authenticate HMAC?

    - by mrwooster
    I am designing a simple webservice and want to use HMAC for authentication to the service. For the purpose of this question we have: a web service at example.com a secret key shared between a user and the server [K] a consumer ID which is known to the user and the server (but is not necessarily secret) [D] a message which we wish to send to the server [M] The standard HMAC implementation would involve using the secret key [K] and the message [M] to create the hash [H], but I am running into issues with this. The message [M] can be quite long and tends to be read from a file. I have found its very difficult to produce a correct hash consistently across multiple operating systems and programming languages because of hidden characters which make it into various file formats. This is of course bad implementation on the client side (100%), but I would like this webservice to be easily accessible and not have trouble with different file formats. I was thinking of an alternative, which would allow the use a short (5-10 char) random string [R] rather than the message for autentication, e.g. H = HMAC(K,R) The user then passes the random string to the server and the server checks the HMAC server side (using random string + shared secret). As far as I can see, this produces the following issues: There is no message integrity - this is ok message integrity is not important for this service A user could re-use the hash with a different message - I can see 2 ways around this Combine the random string with a timestamp so the hash is only valid for a set period of time Only allow each random string to be used once Since the client is in control of the random string, it is easier to look for collisions I should point out that the principle reason for authentication is to implement rate limiting on the API service. There is zero need for message integrity, and its not a big deal if someone can forge a single request (but it is if they can forge a very large number very quickly). I know that the correct answer is to make sure the message [M] is the same on all platforms/languages before hashing it. But, taking that out of the equation, is the above proposal an acceptable 2nd best?

    Read the article

  • Random numbers from -10 to 10 in C++

    - by Chris_45
    How does one make random numbers in the interval -10 to 10 in C++ ? srand(int(time(0)));//seed for(int i = 0; i < size; i++){ myArray[i] = 1 + rand() % 20 - 10;//this will give from -9 to 10 myArray2[i] =rand() % 20 - 10;//and this will -10 to 9 }

    Read the article

  • SQL Random number not working

    - by JMSA
    declare @fieldForceCounter as int declare @SaleDate as dateTime declare @RandomNoSeed as decimal set @fieldForceCounter = 1 set @SaleDate = '1 Jan 2009' set @RandomNoSeed = 0.0 WHILE @fieldForceCounter <= 3 BEGIN while @SaleDate <= '1 Dec 2009' begin INSERT INTO MonthlySales(FFCode, SaleDate, SaleValue) VALUES(@fieldForceCounter, @SaleDate, RAND(@RandomNoSeed)) set @saleDate = @saleDate + 1 set @RandomNoSeed = Rand(@RandomNoSeed) + 1 end set @SaleDate = '1 Jan 2009' set @fieldForceCounter = @fieldForceCounter + 1 END GO This T-SQL command was supposed to insert random values in the 'SaleValue'-column in the 'MonthlySales'-table. But it is inserting '1' every time . What can be the problem?

    Read the article

  • Random loading swf files into main swf with countdown timer

    - by Plugger
    ok guys a question, can this be done or has it already been done, or can someone point me in the right direction (be aware i an a total newbie with action script) i have a main swf movie about 600px x 400 px what i want is this to run for say 30 seconds, then i want a countdown timer in the bottom corner for say 10 seconds, after this i want it to randomly load another swf file over the top of the original, and then the timer repeats for 10 seconds and repates the random loading of another swf file over the top etc, etc, etc so whats the best way around this

    Read the article

  • TeamCity build number versus Ant build number task

    - by jonny
    I have a build project that I run from TeamCity, now it takes the build.number from TeamCity. I want to be able to use the buildnumber task (Ant) which in my understanding when used, is supposed to change the value of build number property and increment it for next time. But it seems that I still get the build number from TeamCity. How can I use the build number from <buildnumber file="mybuild.number"/>?

    Read the article

  • Random record in ActiveRecord

    - by astrofoo
    I'm in need of getting a random record from a table via ActiveRecord. I've followed the example from Jamis Buck from 2006. However, I've also come across another way via a Google search (can't attribute with a link due to new user restrictions): rand_id = rand(Model.count) rand_record = Model.first(:conditions => [ "id >= ?", rand_id]) I'm curious how others on here have done it or if anyone knows what way would be more efficient.

    Read the article

  • Initializing a C++ vector to random values... fast

    - by Flamewires
    Hey, id like to make this as fast as possible because it gets called A LOT in a program i'm writing, so is there any faster way to initialize a C++ vector to random values than: double range;//set to the range of a particular function i want to evaluate. std::vector<double> x(30, 0.0); for (int i=0;i<x.size();i++) { x.at(i) = (rand()/(double)RAND_MAX)*range; } EDIT:Fixed x's initializer.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >