Search Results

Search found 3141 results on 126 pages for 'zero'.

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

  • SQLite SQLite column can't be updated to any value but zero (real type)

    - by user1065320
    Hi I'm trying to create a three fields table (date,text,real), I can insert and update the first two fields but can't set or update the last one. createSQL = @"CREATE TABLE IF NOT EXISTS ACTIVITIES (MYDATE DATETIME PRIMARY KEY, ACTIVITY TEXT , LENGTH REAL);"; try to insert char *update = "INSERT OR REPLACE INTO ACTIVITIES (MYDATE, ACTIVITY , LENGTH) VALUES (?, ? ,?);"; sqlite3_stmt *stmt; if (sqlite3_prepare_v2(database, update , -1, &stmt, nil) == SQLITE_OK) { sqlite3_bind_double(stmt, 1, valueToWrite); sqlite3_bind_text(stmt, 2, [task UTF8String], -1, NULL); sqlite3_bind_double(stmt, 3, 1.5); } if (sqlite3_step(stmt) != SQLITE_DONE) { NSAssert1(0, @"Error updating table: %s", errorMsg); } sqlite3_finalize(stmt); sqlite3_close(database); The first two values are updated but the last one remains 0 even if I'm writing a value like 1.5 or put a double variable with a different value Thanks

    Read the article

  • sql boolean truth test: zero OR null

    - by AK
    Is there way to test for both 0 and NULL with one equality operator? I realize I could do this: WHERE field = 0 OR field IS NULL But my life would be a hundred times easier if this would work: WHERE field IN (0, NULL) (btw, why doesn't that work?) I've also read about converting NULL to 0 in the SELECT statement (with COALESCE). The framework I'm using would also make this unpleasant. Realize this is oddly specific, but is there any way to test for 0 and NULL with one WHERE predicate?

    Read the article

  • Programming tutorials for people with zero experience

    - by www.aegisub.net
    A friend of mine is interested in learning how to program computers, but she knows nothing about programming. I suggested that Python might be a good language to start with, but after some googling, I couldn't find any tutorials that covered both programming and Python in an adequate way. I don't want her to go through the tiresome "learn algorithms in pseudocode first" routine. Instead, I'd like a tutorial that will explain the basic ideas while working towards a real goal, e.g. a very simple console game. Does anyone know of any such tutorials? Do you think that I'm mistaken in how I'm handling this? Is Python a bad choice? I know that something like C, C++ or Java won't work - too many details will be very counterproductive. On the other hand, I think that Lisp might be too mathematical and abstract. Python, on the other hand, will let her even do something like coding primitive graphical games in a short period of time.

    Read the article

  • Cannot compute equation, always gives zero

    - by user1738391
    Did i miss something? The variable percentage_ always equals 0. I've checked nTimes and winnings, they give the correct values as what is being input. Even when I test out a simple equation like, percentage_=1+1, percentage_ will give 0. Can someone help? #pragma once #include <iostream> #include <string> #include <cstdlib> #include <iomanip> using namespace std; class GuessMachine { private: int nTimes; int winnings; string nM[6]; public: GuessMachine(); void displayPrizes(); void displayMenu(); int getInput(); void checkNumber(); void checkPrize(); }; void GuessMachine::checkPrize() { MagicNumber mn; int prize_=mn.generateNumber(); float percentage_; percentage_ = float (winnings/nTimes*100); //<--On this line percentage is always 0 no matter what winnings and nTimes are cout<<"Percentage is "<<percentage_<<endl; if(percentage_ >= 50) { cout<<"You have scored "<<percentage_<<"% and won "<<nM[prize_]; } else { cout<<"You have scored "<<percentage_<<"%. You lose!!"; } cin.ignore(); cin.ignore(); }

    Read the article

  • The sign of zero with float2

    - by JackOLantern
    Consider the following code performing operations on complex numbers with C/C++'s float: float real_part = log(3.f); float imag_part = 0.f; float real_part2 = (imag_part)*(imag_part)-(real_part*real_part); float imag_part2 = (imag_part)*(real_part)+(real_part*imag_part); The result will be real_part2= -1.20695 imag_part2= 0 angle= 3.14159 where angle is the phase of the complex number and, in this case, is pi. Now consider the following code: float real_part = log(3.f); float imag_part = 0.f; float real_part2 = (-imag_part)*(-imag_part)-(real_part)*(real_part); float imag_part2 = (-imag_part)*(real_part)+(real_part)*(-imag_part); The result will be real_part2= -1.20695 imag_part2= 0 angle= -3.14159 The imaginary part of the result is -0 which makes the phase of the result be -pi. Although still accomplishing with the principal argument of a complex number and with the signed property of floating point's 0, this changes is a problem when one is defining functions of complex numbers. For example, if one is defining sqrt of a complex number by the de Moivre formula, this will change the sign of the imaginary part of the result to a wrong value. How to deal with this effect?

    Read the article

  • LINQ2SQL: How to let a column accept null values as zero (0) in Self-Relation table

    - by Remon
    As described in the img, I got a parent-Children relation and since the ParentID not accepting null values (and I can't change to nullabel due to some restriction in the UI I have), how can I remove an existence relation between ReportDataSources in order to change the parent for them (here i want to set the parentId for one of them = 0) how could i do that since i cant change the ParentID directly and setting Parent = null is not valid public void SetReportDataSourceAsMaster(ReportDataSource reportDataSource) { //Some logic - not necessarily for this scenario //Reset Master this.ReportDataSources.ToList().ForEach(rds => rds.IsMaster = false); //Set Master reportDataSource.IsMaster = true; //Set Parent ID for the rest of the Reports data sources this.ReportDataSources.Where(rds => rds.ID != reportDataSource.ID).ToList().ForEach(rds => { //Change Parent ID rds.Parent = reportDataSource; //Remove filttering data rds.FilteringDataMembers.Clear(); //Remove Grouping Data rds.GroupingDataMembers.Clear(); }); //Delete parent HERE THE EXCEPTION THROWN AFTER CALLING SUBMITCHANGES() reportDataSource.Parent = null; //Other logic } Exception thrown after calling submitChanges An attempt was made to remove a relationship between a ReportDataSource and a ReportDataSource. However, one of the relationship's foreign keys (ReportDataSource.ParentID) cannot be set to null.

    Read the article

  • Replacing emty csv column values with a zero

    - by homerjay
    Hey, So I'm dealing with a csv file that has missing values. What I want my script to is: #!/usr/bin/python import csv import sys #1. Place each record of a file in a list. #2. Iterate thru each element of the list and get its length. #3. If the length is less than one replace with value x. reader = csv.reader(open(sys.argv[1], "rb")) for row in reader: for x in row[:]: if len(x)< 1: x = 0 print x print row Here is an example of data, I trying it on, ideally it should work on any column lenghth Before: actnum,col2,col4 xxxxx , , xxxxx , 845 , xxxxx , ,545 After actnum,col2,col4 xxxxx , 0 , 0 xxxxx , 845, 0 xxxxx , 0 ,545 Any guidance would be appreciated

    Read the article

  • Centering Divisions Around Zero

    - by Mark
    I'm trying to create something that sort of resembles a histogram. I'm trying to create buckets from an array. Suppose I have a random array doubles between -10 and 10; this is very simplified. I then want to specify a center point, in this case 0 and the number of buckets. If I want 4 buckets the division would be -10 to -5, -5 to 0, 0 to 5 and 5 to 10. Not that complicated right. Now if I change the min and max to -12 and -9 and as for 4 divisions its more complicated. I either want a division at -3 and 3; it is centered around 0 ; or one at -6 to 0 and 0 to 6. Its not that hard to find the division size = Math.Ceiling((Abs(Max) + Abs(Min)) / Divisions) Then you would basically have an if statement to determine whether you want it centered on 0 or on an edge. You then iterate out from either 0 or DivisionSize/2 depending on the situation. You may not ALWAYS end up with the specified number of divisions but it will be close. Then you iterate through the array and increment the bin count. Does this seem like a good way to go about this? This method would surely work but it does not seem to be the most elegant. I'm curious as to whether the creation of the bins and the counting from the list could be done in a clever class with linq in a more elegant way? Something like creating the bins and then having each bin be a property {get;} that returns list.Count(x=> x >= Lower && x < Upper).

    Read the article

  • Array length is zero in jQuery.

    - by James123
    I wrote like this. After submit click loop is not excuting. But I saw value are there, But array lenght is showing '0'. (Please see picture). Why it is not going into loop? and $('#myVisibleRows').val(idsString); becoming 'empty'. $(document).ready(function() { $('tr[@class^=RegText]').hide().children('td'); var list_Visible_Ids = []; var idsString, idsArray; alert($('#myVisibleRows').val()); idsString = $('#myVisibleRows').val(); idsArray = idsString.split(','); $.each(idsArray, function() { if (this != "") { $('#' + this).siblings(('.RegText').toggle(true)); window['list_Visible_Ids'][this] = 1; } }); $('tr.subCategory1') .css("cursor", "pointer") .attr("title", "Click to expand/collapse") .click(function() { //this = $(this); $(this).siblings('.RegText').toggle(); list_Visible_Ids[$(this).attr('id')] = $(this).css('display') != 'none' ? 1 : null; alert(list_Visible_Ids[$(this).attr('id')]) }); $('#form1').submit(function() { idsString = ''; $.each(list_Visible_Ids, function(key, val) { alert(val); if (val) { idsString += (idsString != '' ? ',' : '') + key; } }); $('#myVisibleRows').val(idsString); form.submit(); }); });

    Read the article

  • Symfony: there is a "0" (zero) in a sfWidgetFormChoice

    - by user248959
    Hi, i want to show a select which options are the character '-' and a range of integers. I have this: $years = range(14,130); new sfWidgetFormChoice(array('choices' => array_merge(array('' => '-',array_combine($years,$years))); The problem: between the '-' and the range of integers there is a "0" (bold and italic). Any help? Regards Javi

    Read the article

  • Des failles zero-day découvertes dans MySQL, pouvant entraîner un crash du SGBD ou bloquer l'accès aux utilisateurs

    Des failles zero-day découvertes dans MySQL pouvant entraîner un crash du SGBD ou bloquer l'accès aux utilisateurs Des chercheurs en sécurité viennent de découvrir plusieurs vulnérabilités critiques zero-day dans le gestionnaire de bases de données MySQL. Identifiées au nombre de cinq initialement, c'est finalement trois failles qui se sont avérées être importantes. Les vulnérabilités peuvent être exploitées par des pirates pour bloquer l'accès au SGBD à des utilisateurs et dans une certaine mesure, entrainer même un crash de MySQL. Les failles de sécurité répertoriées sous les références allant de CVE-2012-5611 à 5615, sont décrites comme pouvant entrainer des dépas...

    Read the article

  • SQL: How do I return zeroes where there is nothing to aggregate across?

    - by Karl
    Hi What I would like ask is best illustrated by an example, so bear with me. Suppose I have the following table: TypeID Gender Count 1 M 10 1 F 3 1 F 6 3 M 11 3 M 8 I would like to aggregate this for every possible combination of TypeID and Gender. Where TypeID can be 1,2 or 3 and Gender can be M or F. So what I want is the following: TypeID Gender SUM(Count) 1 M 10 1 F 9 2 M 0 2 F 0 3 M 19 3 F 0 I can think of a few ways to potentially do this, but none of them seem particularly elegant to me. Any suggestions would be greatly appreciated! Karl

    Read the article

  • C++ double division by 0.0 versus DBL_MIN

    - by wonsungi
    When finding the inverse square root of a double, is it better to clamp invalid non-positive inputs at 0.0 or MIN_DBL? (In my example below double b may end up being negative due to floating point rounding errors and because the laws of physics are slightly slightly fudged in the game.) Both division by 0.0 and MIN_DBL produce the same outcome in the game because 1/0.0 and 1/DBL_MIN are effectively infinity. My intuition says MIN_DBL is the better choice, but would there be any case for using 0.0? Like perhaps sqrt(0.0), 1/0.0 and multiplication by 1.#INF000000000000 execute faster because they are special cases. double b = 1 - v.length_squared()/(c*c); #ifdef CLAMP_BY_0 if (b < 0.0) b = 0.0; #endif #ifdef CLAMP_BY_DBL_MIN if (b <= 0.0) b = DBL_MIN; #endif double lorentz_factor = 1/sqrt(b); double division in MSVC: 1/0.0 = 1.#INF000000000000 1/DBL_MIN = 4.4942328371557898e+307

    Read the article

  • PayPal $0 Dollar Transaction?

    - by Alex
    Hi. I have a client who wants a paypal shopping cart. All of the services have "Buy Now" buttons, all with different prices. However, there is one service, which is a FREE 0 dollar service. The client wants the "Buy Now" button to remain there, to be consistent with the rest of the site. Does anyone know how I can do a $0 dollar transaction with paypal? I can't find any insight on this being possible. Thanks.

    Read the article

  • Prevent printing -0

    - by fishinear
    If I do the following in Objective-C: NSString *result = [NSString stringWithFormat:@"%1.1f", -0.01]; It will give result @"-0.0" Does anybody know how I can force a result @"0.0" (without the "-") in this case? EDIT: I tried using NSNumberFormatter, but it has the same issue. The following also produces @"-0.0": double value = -0.01; NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; [numberFormatter setMaximumFractionDigits:1]; [numberFormatter setMinimumFractionDigits:1]; NSString *result = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:value]];

    Read the article

  • Excel - Variable number of leading zeros in variable length numbers?

    - by daltec
    The format of our member numbers has changed several times over the years, such that 00008, 9538, 746, 0746, 00746, 100125, and various other permutations are valid, unique and need to be retained. Exporting from our database into the custom Excel template needed for a mass update strips the leading zeros, such that 00746 and 0746 are all truncated to 746. Inserting the apostrophe trick, or formatting as text, does not work in our case, since the data seems to be already altered by the time we open it in Excel. Formatting as zip won't work since we have valid numbers less than five digits in length that cannot have zeros added to them. And I am not having any luck with "custom" formatting as that seems to require either adding the same number of leading zeros to a number, or adding enough zeros to every number to make them all the same length. Any clues? I wish there was some way to set Excel to just take what it's given and leave it alone, but that does not seem to be the case! I would appreciate any suggestions or advice. Thank you all very much in advance!

    Read the article

  • PHP: Check if 0?

    - by tarnfeld
    Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the values in a cell are 0. The class returns me a number 0 so it's nothing to do with the class, I think it's the way I am looping through the rows and then assigning them to the array... I want to carry through the 0 value because I am creating graphs with the data afterwards, here is the code I have. // Get Rainfall $rainfall = array(); for($i=1;$i<=$count;$i++) { if($data->val($i,2) != 'Rainfall') // Check if not the column title { $rainfall[] = $data->val($i,2); } } For your info $data is the excel spreadsheet object and the method $data->val(row,col) is what returns me the value. In this case I am getting data from column 2. Screenshot of spreadsheet http://cl.ly/1Dmy Thanks! All help is very much appreciated!

    Read the article

  • How to account for non-prime numbers 0 and 1 in java?

    - by shady
    I'm not sure if this is the right place to be asking this, but I've been searching for a solution for this on my own for quite some time, so hopefully I've come to the right place. When calculating prime numbers, the starting number that each number has to be divisible by is 2 to be a non-prime number. In my java program, I want to include all the non-prime numbers in the range from 0 to a certain number, so how do I include 0 and 1? Should I just have separate if and else-if statements for 0 and 1 that state that they are not prime numbers? I think that maybe 0 and 1 should be included in the java for loop, but I don't know how to go about doing that. for (int i = 2; i < num; i++){ if (num % i == 0){ System.out.println(i + " is not a prime number. "); } else{ System.out.println(i + " is a prime number. "); } }

    Read the article

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