Search Results

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

Page 109/1194 | < Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >

  • Getting $n number of maximum values

    - by KPL
    Hello all, Straight to the question - If $n = 3, and input is - Array ( [04] => 3 [07] => 4 [01] => 5 [06] => 5 [05] => 5 [03] => 6 [08] => 6 [02] => 7 [09] => 8 [12] => 9 [10] => 10 [15] => 10 [19] => 11 [20] => 11 [13] => 12 [21] => 12 [16] => 13 [14] => 14 [22] => 14 [23] => 15 [11] => 15 [00] => 15 [17] => 17 [18] => 17 ) Output should be - Array ( [14] => 14 [22] => 14 [23] => 15 [11] => 15 [00] => 15 [17] => 17 [18] => 17 ) Thank you, all, for help.

    Read the article

  • Convert long number as string in the serialization

    - by Bruno
    I have a custom made class that use a long as ID. However, when I call my action using ajax, my ID is truncated and it loses the last 2 numbers because javascript loses precision when dealing with large numbers. My solution would be to give a string to my javascript, but the ID have to stay as a long on the server side. Is there a way to serialize the property as a string? I'm looking for some kind of attribute. Controller public class CustomersController : ApiController { public IEnumerable<CustomerEntity> Get() { yield return new CustomerEntity() { ID = 1306270928525862486, Name = "Test" }; } } Model public class CustomerEntity { public long ID { get; set; } public string Name { get; set; } } JSON Result [{"Name":"Test","ID":1306270928525862400}]

    Read the article

  • C# Array number sorting

    - by athgap
    Hi, I have an array of numbers jumbled up from 0-9. How do I sort them in ascending order? Array.Sort doesn't work for me. Is there another way to do it? Thanks in advance. EDIT: Array.Sort gives me this error. Argument 1: cannot convert from 'string' to 'System.Array' Right now it gives me this output: 0) VersionInfo.xml 2) luizafroes_singapore2951478702.xml 3) virua837890738.xml 4) darkwizar9102314425644.xml 5) snarterz_584609551.xml 6) alysiayeo594136055.xml 1) z-a-n-n2306499277.xml 7) zhangliyi_memories932668799030.xml 8) andy_tan911368887723.xml 9) config.xml k are the numbers from 0-9 string[] valnames = rk2.GetValueNames(); foreach (string k in valnames) { if (k == "MRUListEx") { continue; } Byte[] byteValue = (Byte[])rk2.GetValue(k); UnicodeEncoding unicode = new UnicodeEncoding(); string val = unicode.GetString(byteValue); Array.Sort(k); //Error here richTextBoxRecentDoc.AppendText("\n" + k + ") " + val + "\n"); }

    Read the article

  • Single page app with high number of images working extremely slow on iOS8 safari/Webview

    - by NikhilWanpal
    We are working on a WebView (not WKWebView, yet) app, are are observing that the app runs extremely slow on iOS 8. The same app runs smooth on lower versions of OS like iOS7 and iOS6. So we tried it in safari on iOS8 and the performance is similar to iOS6 and 7. The app is filled with images and many are high resolution. While trying to trace the issue (trial and error!) we reduced the sizes and resolutions of the images and the performance improved, but it is still not at par with versions 6 and 7. We are unable to find any such issues reported elsewhere and are stuck. It would be great if we could get some pointers on this one.

    Read the article

  • Limit to 10 number of annotations in mapkit!

    - by teddafan
    Hi, I have all my annotations(as nsdictionnaries) in an array , and the users add them one by one by tapping on an icon. I want to make it impossible after adding 10 annotations (there is 110). Is it here i have to make something?: -(IBAction) plusButtonTapped: (id) sender { NSDictionary *poiDict = [poiArray objectAtIndex:nextPoiIndex++]; CLLocationCoordinate2D poiCoordinate; poiCoordinate.latitude = [[poiDict valueForKey:@"workingCoordinate.latitude"] doubleValue]; poiCoordinate.longitude = [[poiDict valueForKey:@"workingCoordinate.longitude"] doubleValue]; MyMapAnnotation *poiAnnotation = [[MyMapAnnotation alloc] initWithCoordinate:poiCoordinate title:[poiDict valueForKey:@"Subtitle"] color:MKPinAnnotationColorRed ]; [mapView addAnnotation:poiAnnotation]; [self adjustMapZoom]; } Thank you for your help in advance, teddafan

    Read the article

  • do.call(rbind, list) for uneven number of column

    - by h.l.m
    I have a list, with each element being a character vector, of differing lengths I would like to bind the data as rows, so that the column names 'line up' and if there is extra data then create column and if there is missing data then create NAs Below is a mock example of the data I am working with x <- list() x[[1]] <- letters[seq(2,20,by=2)] names(x[[1]]) <- LETTERS[c(1:length(x[[1]]))] x[[2]] <- letters[seq(3,20, by=3)] names(x[[2]]) <- LETTERS[seq(3,20, by=3)] x[[3]] <- letters[seq(4,20, by=4)] names(x[[3]]) <- LETTERS[seq(4,20, by=4)] The below line would normally be what I would do if I was sure that the format for each element was the same... do.call(rbind,x) I was hoping that someone had come up with a nice little solution that matches up the column names and fills in blanks with NAs whilst adding new columns if in the binding process new columns are found...

    Read the article

  • Reduce the number of queries in EF

    - by Gio2k
    I have the following Model: Entities: Product (Contains basic data for products: price, etc) Attribute (Contains data for all possible optional attributes) ProductAttribute (Contains data for optional attributes of a product, eg. Color, Model, Size). ProductAttribute is essentially a many to many relationship with payload (ProductId, AttributeID, Value) And this piece of code: private static void ListAttributes(Product p) { p.ProductAttributes.Load(); foreach (var att in p.ProductAttributes) { att.Attribute.load(); Console.WriteLine("\tAttribute Name:{0} - Value {1}", att.Attribute.Name, att.AttributeValue); } } This piece of code will fire a query for each time the att.Attribute.Load() method is called in the foreach loop, only so i can get display the name of the attribute. I would like to fetch the Attribute.Name together with the query that fetches all attribute values, i.e. join ProductAttribute and Attribute. Is there any way to achieve this within my method?

    Read the article

  • Generate a sequence of Fibonacci number in Scala

    - by qin
    def fibSeq(n: Int): List[Int] = { var ret = scala.collection.mutable.ListBuffer[Int](1, 2) while (ret(ret.length - 1) < n) { val temp = ret(ret.length - 1) + ret(ret.length - 2) if (temp >= n) { return ret.toList } ret += temp } ret.toList } So the above is my code to generate a Fibonacci sequence using Scala to a value n. I am wondering if there is a more elegant way to do this in Scala?

    Read the article

  • Number distribution

    - by Carra
    Problem: We have x checkboxes and we want to check y of them evenly. Example 1: select 50 checkboxes of 100 total. [-] [x] [-] [x] ... Example 2: select 33 checkboxes of 100 total. [-] [-] [x] [-] [-] [x] ... Example 3: select 66 checkboxes of 100 total: [-] [x] [x] [-] [x] [x] ... But we're having trouble to come up with a formula to check them in code, especially once you go 11/111 or something similar. Anyone has an idea?

    Read the article

  • Count the number of dates between two dates

    - by Matt Mitchell
    I'm looking to count the dates covered (inclusive) between two DateTimes (not .TotalDays) For example: 2012-2-1 14:00 to 2012-2-2 23:00 -> 2 2012-2-1 14:00 to 2012-2-2 10:00 -> 2 2012-2-1 14:00 to 2012-2-1 15:00 -> 1 2012-1-1 00:00 to 2012-12-31 23:59 -> 366 I can get this functionality with the code below: DateTime dt1 = new DateTime(2000,1,2,12,00,00); DateTime dt2 = new DateTime(2000,1,3,03,00,00); int count = 0; for (DateTime date = dt1; date.Date <= dt2.Date; date = date.AddDays(1)) count++; return count; Is there a better way?

    Read the article

  • Count total number of callers?

    - by Kristopher Ives
    I'm currently doing this query to find the guy who makes the most calls: SELECT `commenter_name`, COUNT(*) AS `calls` FROM `comments` GROUP BY `commenter_name` ORDER BY `calls` LIMIT 1 What I want now is to be able to find out how many total unique callers. I tried using DISTINCT but I didn't get anywhere.

    Read the article

  • kQuery : Trying to find a specific instance of a class by number

    - by mattelliottIT
    I guess I have just hit a mental block with this one; maybe some fresh eyes will help. Basically I have a few instance of the class "menu-item" which when clicked call the click function via jQuery and bring up a video. Instead of giving each on an id as well as a class I am trying to find which instance of the class was clicked (1, 2, 3, etc). Just can't seem to get it though. //click listener for menu-items $('.menu-item').click(function(event) { var o = $('.menu-item'); var count = o.length(); // switch(count) { case 0 : filename == 'letters'; break; case 1 : filename == 'the-gift'; break; } var videoPlayer = '<video controls width="618px">'; videoPlayer += '<source src="_video/' + filename + '.mp4" />'; videoPlayer += '</video>'; //place video $('#videoCont').html(videoPlayer); }); I'm trying to create an array there where each instance of the 'menu-item' is one array item. (btw, for now I am just proofing this with an mp4 filetype before I add in the ogv and webm formats). Thanks for any and all help!

    Read the article

  • Using pow() for large number

    - by g4ur4v
    I am trying to solve a problem, a part of which requires me to calculate (2^n)%1000000007 , where n<=10^9. But my following code gives me output "0" even for input like n=99. Is there anyway other than having a loop which multilplies the output by 2 every time and finding the modulo every time (this is not I am looking for as this will be very slow for large numbers). #include<stdio.h> #include<math.h> #include<iostream> using namespace std; int main() { unsigned long long gaps,total; while(1) { cin>>gaps; total=(unsigned long long)powf(2,gaps)%1000000007; cout<<total<<endl; } }

    Read the article

  • extract number of A tags using jquery

    - by user1017268
    I am working on an enterprise application where I can have several links present in table or none depending on the data. The links appear in the table and have following code behind them <td class="Row"><span id='s_3_2_14_0' ><a href='JavaScript:SWETargetGotoURL("/eservice_enu/start.swe?SWECmd=GotoView&SWEView=Active+PO+Serial+View&SWEPostnApplet=Purchase+Order+List+Applet&SWEPostnRowId=1-KPBLOZ","_self")'>2001103009</a></span></td> I need to find all the A tags present in the page inside SPAN tag having following text SWEView=Active+PO+Serial+View&SWEPostnApplet=Purchase+Order+List+Applet I tried the following expression but it returns 0 $('a[href*="SWEView=Active+PO+Serial+View&SWEPostnApplet=Purchase+Order+List+Applet"').length;

    Read the article

  • How to check if *number* is in a array

    - by Emil
    Pretty basic programming question, I know PHP have a function for it, but does the iPhone OS have one? I want to check if the current indexPath is a value in an array. PHP Example: <?php $indexPath = 3; $array = array("0", "1", "2", "3", "4"); if (in_array($indexPath, $array)) { // Do something } ?> Does anybody know how to do the same thing inthe iPhone OS?

    Read the article

  • VS2008 intellisense performance issue with large number of partial static classes

    - by scebula
    My question is a follow-up to the issue posted here regarding the Intellisense performance issue when building a large solution in VS2008 that has many partial static classes. Since Microsoft does not seem to be addressing the issue for VS2008, I would like to know if there are other ways around the problem? Waiting for VS2010 is not an option at this time. The proposed solution in the previous post is not practical as some of the partial classes may be regenerated and this would be a maintenance headache.

    Read the article

< Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >