Search Results

Search found 2886 results on 116 pages for 'behaviour'.

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

  • C function changes behaviour depending on whether it has a call to printf in it

    - by Daniel
    I have a function that processes some data and finds the threshold that classifies the data with the lowest error. It looks like this: void find_threshold(FeatureVal* fvals, sampledata* data, unsigned int num_samples, double* thresh, double* err, int* pol) { //code to calculate minThresh, minErr, minPol omitted printf("minThresh: %f, minErr: %f, minPol: %d\n", minThresh, minErr, minPol); *thresh = minThresh; *err = minErr; *pol = minPol; } Then in my test file I have this: void test_find_threshold() { //code to set up test data omitted find_threshold(fvals, sdata, 6, &thresh, &err, &pol); printf("Expected 5 got %f\n", thresh); assert(eq(thresh, 5.0)); printf("Expected 1 got %d\n", pol); assert(pol == 1); printf("Expected 0 got %f\n", err); assert(eq(err, 0.0)); } This runs and the test passes with the following output: minThresh: 5.000000, minErr: 0.000000, minPol: 1 Expected 5 got 5.000000 Expected 1 got 1 Expected 0 got 0.000000 However if I remove the call to printf() from find_threshold, suddenly the test fails! Commenting out the asserts so that I can see what gets returned, the output is: Expected 5 got -15.000000 Expected 1 got -1 Expected 0 got 0.333333 I cannot make any sense of this whatsoever.

    Read the article

  • Jquery click behaviour

    - by VP
    I'm developing a menu. This menu, will change the background image when you click on a link, as almost all menus does. if i click in one link from the menu, this link backgroun will change the color. My jquery script is: $(function() { $('#menu ul li').click(function() { $('#menu ul li').removeClass("current_page_item"); $(this).addClass("current_page_item"); //return false; }); }); today, with the "return false" commented, when i click on the link under "#menu ul li" it changes the background open the new page and the background is reseted. For sure, if i uncomment the return false, the background works fine but then i cannot open any link. So its looks like after that i open a new page, it reset the classes. How can i make it persistent?

    Read the article

  • More specific NSNumberFormatter failure behaviour

    - by Volte
    I have an NSTextField into which I need the user to enter a number between a max and min, and it would be nice if I could detect when the NSNumberFormatter fails that particular test so I can either display a nicer message ("The number is too large" is not very helpful, it needs to display the valid range) or simply set the field automatically to the nearest valid value. I've looked at the NSTextField delegate's -control:didFailToFormatString:errorDescription: method which doesn't seem to allow you to modify the error, and I've looked at overriding the NSNumberFormatter's -getObjectValue:forString:range:error: method which does give me an NSError that I can modify, but there doesn't seem to be any way to determine which specific error was returned. Since I am just entering a simple integer, I don't need most of the functionality in NSNumberFormatter, would I be better off just writing my own formatter from scratch?

    Read the article

  • C# Localization - unexpected behaviour

    - by vikp
    Hi, I have the following line of code: <%= Html.Label((string) GetLocalResourceObject("Label_Email")) %> This generates a label within an HTML page. In the local resource file I have the following entry: Name: Label_Email Value:Email For some very strange reason when I load the page in the browser, it generates an HTML label with a value of "Email Address" instead of "Email". This is a serious problem for me because I need to localize the application and not have english word "address". When I replace Value in the local resouce file with "Email " (notice extra space), everything works fine, but this is a hack and I need to understand why my application is behaving this way. Thank you

    Read the article

  • Strange behaviour with Microsoft.WindowsCE.Forms

    - by Mohammadreza
    I have a Windows Mobile application in which I want to check the device orientation. Therefore I wrote the following property in one of my forms: internal static Microsoft.WindowsCE.Forms.ScreenOrientation DeviceOriginalOrientation { get; private set; } The strange thing is that after that whenever I open a UserControl, the designer shows this warning even if that UserControl doesn't use the property: Could not load file or assembly 'Microsoft.WindowsCE.Forms, Version=3.5.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Commenting the above property will dismiss the warning and shows the user control again. The application is built successfully and runs without any problems in both cases. Does anybody know why this happens and how can I fix it?

    Read the article

  • Git strange behaviour

    - by pocoa
    git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: readme.txt # modified: requirements.txt # no changes added to commit (use "git add" and/or "git commit -a") I didn't make any changes on those files. But I'm getting this message even if I try: git checkout -- readme.txt git checkout -- requirements.txt When I run: git diff it shows the whole file as updated. But the contents are the same. I tried to delete them and checkout again, but it didn't work.

    Read the article

  • IntelliJ IDEA non standard caret behaviour

    - by Vaat666
    I have an issue with IntelliJ IDEA when selecting a big amount of text, and I cannot find the parameter to set to change that. Here is an example of the situation: My caret is on line 3 I scroll with the mouse wheel towards line 300 I press ctrl + shift I press the left button of the mouse Such an action would result in the text from line 3 to 300 being selected in all common editors (even in MS-Word I think), but not in IntelliJ. Do you know how to set this right? Thanks!

    Read the article

  • About the forward and backward a word behaviour in Emacs

    - by janoChen
    I don't know if there's something wrong with my settings but when I press M-f (forward a word) it doesn't matter where I am, it never place the cursor in the next word (just between words). This doesn't happen with M-b which place my cursor in the beginning of the previous word. Is this a normal behavior? How do I place my cursor at the beginning of the following word?

    Read the article

  • `var = something rescue nil` behaviour

    - by JP
    In ruby you can throw a rescue at the end of an assignment to catch any errors that might come up. I have a function (below: a_function_that_may_fail) where it's convenient to let it throw an error if certain conditions aren't met. The following code works well post = {} # Other Hash stuff post['Caption'] = a_function_that_may_fail rescue nil However I'd like to have post['Caption'] not even set if the function fails. I know I can do: begin post['Caption'] = a_function_that_may_fail recsue end but that feels a little excessive - is there a simpler solution?

    Read the article

  • Strange Bubble sort behaviour.

    - by user271528
    Can anyone explain why this bubble sort function doesn't work and why I loose number in my output. I'm very new to C, so please forgive me if this is something very obvious I have missed. #include <stdio.h> #include int bubble(int array[],int length) { int i, j; int temp; for(i = 0; i < (length); ++i) { for(j = 0; j < (length - 1); ++j) { if(array[i] array[i+1]) { temp = array[i+1]; array[i+1] = array[i]; array[i] = temp; } } } return 0; } int main() { int array[] = {12,234,3452,5643,0}; int i; int length; length = (sizeof(array)/sizeof(int)); printf("Size of array = %d\n", length); bubble(array, length); for (i = 0; i < (length); ++i) { printf("%d\n", array[i]); } return 0; } Output Size of array = 5 12 234 3452 0 0

    Read the article

  • Objective C - Constants with behaviour

    - by Akshay
    Hi, I'm new to Objective C. I am trying to define Constants which have behavior associated with them. So far I have done - @interface Direction : NSObject { NSString *displayName; } -(id)initWithDisplayName:(NSString *)aName; -(id)left; // returns West when North -(id)right; // return East when North @end @implementation Direction -(id)initWithDisplayName:(NSString *)aName { if(self = [super init]) { displayName = aName; } return self; } -(id)left {}; -(id)right {}; @end Direction* North = [Direction initWithDisplayName:@"North"]; // error - initializer element is not constant. This approach results in the indicated error. Is there a better way of doing this in Objective C.

    Read the article

  • Question about C behaviour for unsigned integer underflow

    - by nn
    I have read in many places that integer overflow is well-defined in C unlike the signed counterpart. Is underflow the same? For example: unsigned int x = -1; // Does x == UINT_MAX? Thanks. I can't recall where, but i read somewhere that arithmetic on unsigned integral types is modular, so if that were the case then -1 == UINT_MAX mod (UINT_MAX+1).

    Read the article

  • Weird behaviour of C++ destructors

    - by Vilx-
    #include <iostream> #include <vector> using namespace std; int main() { vector< vector<int> > dp(50000, vector<int>(4, -1)); cout << dp.size(); } This tiny program takes a split second to execute when simply run from the command line. But when run in a debugger, it takes over 8 seconds. Pausing the debugger reveals that it is in the middle of destroying all those vectors. WTF? Note - Visual Studio 2008 SP1, Core 2 Duo 6700 CPU with 2GB of RAM. Added: To clarify, no, I'm not confusing Debug and Release builds. These results are on one and the same .exe, without even any recompiling inbetween. In fact, switching between Debug and Release builds changes nothing.

    Read the article

  • GCC, functions, and pointer arguments, warning behaviour

    - by James Morris
    I've recently updated to a testing distribution, which is now using GCC 4.4.3. Now I've set everything up, I've returned to coding and have built my project and I get one of these horrible messages: *** glibc detected *** ./boxyseq: free(): invalid pointer: 0x0000000001d873e8 *** I absolutely know what is wrong here, but was rather confused as to when I saw my C code where I call a function which frees a dynamically allocated data structure - I had passed it an incompatible pointer type - a pointer to a completely different data structure. warning: passing argument 1 of 'data_A_free' from incompatible pointer type note: expected 'struct data_A *' but argument is of type 'struct data_B *' I'm confused because I'm sure this would have been an error before and compilation would never have completed. Is this not just going to make life more difficult for C programmers? Can I change it back to an error without making a whole bunch of other warnings errors too? Or am I loosing the plot and it's always been a warning?

    Read the article

  • Override ~ behaviour in controls

    - by cpf
    Quick backstory: I'm making a "framed" version of my site that has a different master page than normal (one suitable for iframing). It's accessed by mysite.com/Framed/whatever, instead of mysite.com/whatever. This is rewritten in IIS to mysite.com/whatever?framed=true. That works fine. The issue I'm having is that all the links are relative using a ~ like ~/Server.aspx which works fine in the normal site. I need to override that so instead of producing ../Server.aspx (as it "should") it produces ../Framed/Server.aspx or Server.aspx. Currently this means that the page goes back to it's normal view (mystite.com/whatever2) as soon as you click on a link, I want it to continue to stay in mysite.com/Framed/...

    Read the article

  • Javascript code for handling Form behaviour.

    - by Andrew
    Hello, Here's how the situation looks : I have a couple simple forms <form action='settings.php' method='post'> <input type='hidden' name='setting' value='value1'> <input type='submit' value='Value1'> </form> Other small forms close to it have value2, value3, ... for the specific setting1, etc. Now, I have all these forms placed on the settings.php subpage, but I'd also like to have copies of one or two of them on the index.php subpage (for ease of access, as they are in certain situations rather frequently used). Thing is I do not want those forms based on the index.php to redirect me in any way to settings.php, just post the hidden value to alter settings and that's all. How can I do this with JS ? Cheers

    Read the article

  • NSOperation for animation loop causes strange scrolling behaviour

    - by Tricky
    Hi, I've created an animation loop which I run as an operation in order to keep the rest of my interface responsive. Whilst almost there, there is still one remaining issue. My UIScrollViews don't seem to be reliably picking up when a user touch ends. What this means is, for example, if a user drags down on a scroll view, when they lift their fingers the scrollview doesn't bounce back into place and the scrollbar remains visible. As if the finger hasn't left the screen. It takes another tap on the scrollview for it to snap to its correct position and the scrollbar to fade away... Here's the loop I created in a subclassed NSOperation: (void)main { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; _displayLink = [[CADisplayLink displayLinkWithTarget: self selector: @selector(animationLoop:)] retain]; [_displayLink setFrameInterval: 1.0f]; [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes]; while (![self isCancelled]) { NSAutoreleasePool *loopPool = [[NSAutoreleasePool alloc] init]; [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; [loopPool drain]; } [_displayLink invalidate]; [pool release]; } DOes anyone have any idea what might be going on here, and even better how to fix it... Thanks!

    Read the article

  • Weird Excel bar disgram behaviour

    - by Simon
    Hi I have a very simple question. I wanna have a diagram with the following table Apple 30 40 50 Pears 200 300 400 Bananas 10 20 30 The weird thing, when I try to draw a bar diagram the order of the bars change. So Excel draws me first the Bananas, the the pears and finally the apple bar... Is there anyway to tell Excel 2003 that it keeps the order? Thank you very much

    Read the article

  • SWT TabFolder: Weird Drawing Behaviour

    - by JesperGJensen
    Hello StackOverflow Experts Description I have an SWT Page with a TabFolder with a number of dynamically created TabItems. On each TabItem i crate a Composite and set the TabItem.setControl() to the Composite. I then use this Composite as the page on which i draw my items. I draw a set of Controls, including Textbox's and Labels. For the First, Default Tab, this works fine. No problems. Problem On tabs that is not the first tab i have the following problems: I am unable to visually alter then Edited/Enabled state of my Controls. I am unable to visually set the Text content of my elements My Controls look disabled and have a Greyed out look. But i am able to Select the content with my mouse and use CTRL+C to copy it out. So the text contet is there and they are Editable. Visually it is just not updated. Any comments are appeciated, Any requests for code, examples will be supplied and help Welcommed. Updates I tried added the suggest debug loop to the code, where i attempt to enable my Controls. This was the result: [main] INFO [dk.viking.controller.LayerController] - f038.stklok is now Editable [true] and enabled [true] [main] INFO [dk.viking.controller.LayerController] - true Text {} [main] INFO [dk.viking.controller.LayerController] - true Composite {} [main] INFO [dk.viking.controller.LayerController] - true TabFolder {} [main] INFO [dk.viking.controller.LayerController] - true Shell {Viking GUI}

    Read the article

  • Weird behaviour of a deserialized class

    - by orloffm
    I've got a huge XML file that's being deserialized by XmlSerializer in an XSD-generated class structure. Everything used to work just fine, but now a weird thing started happening. Sometimes (50% of runs) a field of a certain object of a class that's deep in the class tree just changes to a certain value of the same field of a different object of the same class. It happens when entering some function, when debugger steps from opening "{" to the first line of code. I understand that it's stupid question, but maybe someone have any thoughts?

    Read the article

  • Strange behaviour of NSString in NSView

    - by Mee
    Trying to create a Skat-Game, I encountered the following problem: isBidding is a Boolean value indicationg, the program is in a certain state, [desk selected] is a method calling returning the current selected player, chatStrings consists of dictionaries, saving strings with the player, who typed, and what he typed - (void)drawRect:(NSRect)rect { NSMutableDictionary * attributes = [NSMutableDictionary dictionary]; [attributes setObject:[NSFont fontWithName:playerFont size:playerFontSize] forKey:NSFontAttributeName]; [attributes setObject:playerFontColor forKey:NSForegroundColorAttributeName]; [[NSString stringWithFormat:@"Player %i",[desk selected] + 1]drawInRect:playerStringRect withAttributes:attributes]; if (isBidding) { [attributes setObject:[NSFont fontWithName:chatFont size:chatFontSize] forKey:NSFontAttributeName]; [attributes setObject:chatFontColor forKey:NSForegroundColorAttributeName]; int i; for (i = 0; i < [chatStrings count]; i++, yProgress -= 20) { if (isBidding) [[NSString stringWithFormat:@"Player %i bids: %@",[[[chatStrings objectAtIndex:i]valueForKey:@"Player"]intValue], [[chatStrings objectAtIndex:i]valueForKey:@"String"]] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; else [[NSString stringWithFormat:@"Player %i: %@",[[[chatStrings objectAtIndex:i]valueForKey:@"Player"]intValue], [[chatStrings objectAtIndex:i]valueForKey:@"String"]] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; } if (isBidding) [[NSString stringWithFormat:@"Player %i bids: %@",[desk selected] + 1, displayString] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; else [[NSString stringWithFormat:@"Player %i: %@",[desk selected] + 1, displayString] drawAtPoint:NSMakePoint([self bounds].origin.x, yProgress) withAttributes:attributes]; yProgress = chatFontBegin; } } This is the part determining the string's content, the string is contributed by an [event characters] method. -(void)displayChatString:(NSString *)string { displayString = [displayString stringByAppendingString:string]; [self setNeedsDisplay:YES]; } The problem if have is this: when typing in more than two letters the view displays NSRectSet{{{471, 574},{500, 192}}} and returns no more discription when I try to print it. then I get an EXC_BAD_ACCESS message, though I have not released it (as far as I can see) I also created the string with alloc and init, so I cannot be in the autorelease pool. I also tried to watch the process when it changes with the debugger, but I couldn't find any responsible code. As you can see I am still a beginner in Cocoa (and programming in general), so I would be really happy if somebody would help me with this.

    Read the article

  • PHP: Strange behaviour while calling custom php functions

    - by baltusaj
    I am facing a strange behavior while coding in PHP with Flex. Let me explain the situation: I have two funcions lets say: populateTable() //puts some data in a table made with flex createXML() //creates an xml file which is used by Fusion Charts to create a chart Now, if i call populateTable() alone, the table gets populated with data but if i call it with createXML(), the table doesn't get populated but createXML() does it's work i.e. creates an xml file. Even if i run following code, only xml file gets generated but table remains empty whereas i called populateTable() before createXML(). Any idea what may be going wrong? MXML Part <mx:HTTPService id="userRequest" url="request.php" method="POST" resultFormat="e4x"> <mx:request xmlns=""> <getResult>send</getResult> </mx:request> and <mx:DataGrid id="dgUserRequest" dataProvider="{userRequest.lastResult.user}" x="28.5" y="36" width="525" height="250" > <mx:columns> <mx:DataGridColumn headerText="No." dataField="no" /> <mx:DataGridColumn headerText="Name" dataField="name"/> <mx:DataGridColumn headerText="Age" dataField="age"/> </mx:columns> PHP Part <?php //-------------------------------------------------------------------------- function initialize($username,$password,$database) //-------------------------------------------------------------------------- { # Connect to the database $link = mysql_connect("localhost", $username,$password); if (!$link) { die('Could not connected to the database : ' . mysql_error()); } # Select the database $db_selected = mysql_select_db($database, $link); if (!$db_selected) { die ('Could not select the DB : ' . mysql_error()); } // populateTable(); createXML(); # Close database connection } //-------------------------------------------------------------------------- populateTable() //-------------------------------------------------------------------------- { if($_POST['getResult'] == 'send') { $Result = mysql_query("SELECT * FROM session" ); $Return = "<Users>"; $no = 1; while ( $row = mysql_fetch_object( $Result ) ) { $Return .= "<user><no>".$no."</no><name>".$row->name."</name><age>".$row->age."</age><salary>". $row->salary."</salary></session>"; $no=$no+1; $Return .= "</Users>"; mysql_free_result( $Result ); print ($Return); } //-------------------------------------------------------------------------- createXML() //-------------------------------------------------------------------------- { $users=array ( "0"=>array("",0), "1"=>array("Obama",0), "2"=>array("Zardari",0), "3"=>array("Imran Khan",0), "4"=>array("Ahmadenijad",0) ); $selectedUsers=array(1,4); //this means only obama and ahmadenijad are selected and the xml file will contain info related to them only //Extracting salaries of selected users $size=count($users); for($i = 0; $i<$size; $i++) { //initialize temp which will calculate total throughput for each protocol separately $salary = 0; $result = mysql_query("SELECT salary FROM userInfo where name='$users[$selectedUsers[$i]][0]'"); $row = mysql_fetch_array($result)) $salary = $row['salary']; } $users[$selectedUsers[$i]][1]=$salary; } //creating XML string $chartContent = "<chart caption=\"Users Vs Salaries\" formatNumberScale=\"0\" pieSliceDepth=\"30\" startingAngle=\"125\">"; for($i=0;$i<$size;$i++) { $chartContent .= "<set label=\"".$users[$selectedUsers[$i]][0]."\" value=\"".$users[$selectedUsers[$i]][1]."\"/>"; } $chartContent .= "<styles>" . "<definition>" . "<style type=\"font\" name=\"CaptionFont\" size=\"16\" color=\"666666\"/>" . "<style type=\"font\" name=\"SubCaptionFont\" bold=\"0\"/>" . "</definition>" . "<application>" . "<apply toObject=\"caption\" styles=\"CaptionFont\"/>" . "<apply toObject=\"SubCaption\" styles=\"SubCaptionFont\"/>" . "</application>" . "</styles>" . "</chart>"; $file_handle = fopen('ChartData.xml','w'); fwrite($file_handle,$chartContent); fclose($file_handle); } initialize("root","","hiddenpeak"); ?>

    Read the article

  • Weird splitter behaviour when moving it

    - by tomo
    My demo app displays two rectangles which should fill whole browser's screen. There is a vertical splitter between them. This looks like a basic scenario but I have no idea how to implement this in xaml. I cannot force this to fill whole screen and when moving splitter then whole screen grows. Can anybody help? <UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Border BorderBrush="Black" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" MinWidth="50"> </Border> <controls:GridSplitter Grid.Column="1" VerticalAlignment="Stretch" Width="Auto" ></controls:GridSplitter> <Border BorderBrush="Blue" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Column="2" MinWidth="50"></Border> </Grid> </UserControl>

    Read the article

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