Search Results

Search found 2221 results on 89 pages for 'equal'.

Page 51/89 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • Why do the following expanded if shorthand statements not work in javascript?

    - by PeanutsMonkey
    This is my first attempt to write shorthand if statements however am befuddled by why the expanded versions don't work quite the way I imagined they would. Code 1 - Does not work if(document.getElementById == true) { alert("The document object model is supported by: " + navigator.appName); } Code 2 - Does work if(document.getElementById != false) { alert("The document object model is supported by: " + navigator.appName); } Code 3 - The shorthand that does work if(document.getElementById) { alert("The document object model is supported by: " + navigator.appName); } Why is that if I expand the shorthand in 3 to the first code sample not work and why does it work if I have it equal to != false?

    Read the article

  • Question on preprocessor directives

    - by dotnetdev
    If I use proprocessor directives to define which code an OS will run, like so: #if winXP // Compiling for Windows XP platformName = "Microsoft Windows XP"; #elif win2000 // Compiling for Windows 2000 platformName = "Microsoft Windows 2000"; #elif win7 // Compiling for Windows 7 platformName = "Microsoft Windows 7"; #else // Unknown platform specified platformName = "Unknown"; How does the system pick up which OS is being used? This is an example from the book Visual C# 2010 Recipes, where the author says that the platformName variable (declaration ommitted), wil equal the OS above. Thanks

    Read the article

  • Dynamic name of NSMutableDictionary?

    - by Bruno
    Hi everyone I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt. For example, each is like that: id of element | date | text What I'm asking is the equivalent of the NSString stringWithFormat:. Can we do the same for an Mutable Dictionary? To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date]; I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that? Thanks everyone Regards

    Read the article

  • Why only the constant expression can be used as case expression in Switch statement?

    - by sinec
    Hi, what is bothering me is that I can't found an info regarding the question from the title. I found that assembly form the Switch-case statement is compiled into bunch of (MS VC 2008 compiler) cmp and je calls: 0041250C mov eax,dword ptr [i] 0041250F mov dword ptr [ebp-100h],eax 00412515 cmp dword ptr [ebp-100h],1 0041251C je wmain+52h (412532h) 0041251E cmp dword ptr [ebp-100h],2 00412525 je wmain+5Bh (41253Bh) 00412527 cmp dword ptr [ebp-100h],3 0041252E je wmain+64h (412544h) 00412530 jmp wmain+6Bh (41254Bh) where for above code will in case that if condition (i) is equal to 2, jump to address 41253Bh and do execution form there (at 41253Bh starts the code for 'case 2:' block) What I don't understand is why in case that,for instance, function is used as 'case expression', why first function couldn't be evaluated and then its result compared with the condition? Am I missing something? Thank you in advance

    Read the article

  • Mysql query help needed

    - by Me-and-Coding
    Hi, i have two tables category and hotels where category.id should be equal to hotels.catid. Now how do i select 3 rows from each different category from the hotels table. I have this query: select h.* from hotels h inner join category c on h.catid = c.id order by h.catid, h.hid this selects all records, but i want to select three rows per different category so in all it should return 9 rows with 3 rows for each category. If this can not be done in mysql, you could also suggest php code please. Thanks

    Read the article

  • php nested for statements?

    - by Dashiell0415
    I'm trying to process a for loop within a for loop, and just a little wary of the syntax... Will this work? Essentially, I want to run code for every 1,000 records while the count is equal to or less than the $count... Will the syntax below work, or is there a better way? for($x = 0; $x <= 700000; $x++) { for($i = 0; $i <= 1000; $i++) { //run the code } }

    Read the article

  • help implementing algorithm

    - by davit-datuashvili
    http://en.wikipedia.org/wiki/All_nearest_smaller_values this is site of the problem and here is my code but i have some trouble to implement it import java.util.*; public class stack{ public static void main(String[]args){ int x[]=new int[]{ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; Stack<Integer> st=new Stack<Integer>(); for (int a:x){ while (!st.empty() && st.pop()>=a){ System.out.println( st.pop()); if (st.empty()){ break; } else{ st.push(a); } } } } } and here is pseudo code from site S = new empty stack data structure for x in the input sequence: while S is nonempty and the top element of S is greater than or equal to x: pop S if S is empty: x has no preceding smaller value else: the nearest smaller value to x is the top element of S push x onto S

    Read the article

  • C# string equality operator returns false, but I'm pretty sure it should be true... What?!

    - by Daniel Schaffer
    I'm trying to write a unit test for a piece of code that generates a large amount of text. I've run into an issue where the "expected" and "actual" strings appear to be equal, but Assert.AreEqual throws, and both the equality operator and Equals() return false. The result of GetHashCode() is different for both values as well. However, putting both strings into text files and comparing with DiffMerge tells me they're the same. Additionally, using Encoding.ASCII.GetBytes() on both values and then using SequenceEquals to compare the resulting byte arrays returns true. The values are 34KB each, so I'll hold off putting them here for now. Any ideas? I'm completely stumped.

    Read the article

  • Parsing a comma-separated list

    - by alex
    I have a comma-separated list of values, for example: strins s = "param1=true;param2=4;param3=2.0f;param4=sometext;"; I need a functions: public bool ExtractBool(string parameterName, string @params); public int ExtractInt(string parameterName, string @params); public float ExtractFloat(string parameterName, string @params); public string ExtractString(string parameterName, string @params); Is there a special functions in .net that can help me with csl ? PS: parameter names are equal within a list.

    Read the article

  • Scala match/compare enumerations

    - by williamstw
    I have an enumeration that I want to use in pattern matches in an actor. I'm not getting what i'd expect and, now, I'm suspecting I'm missing something simple. My enumeration, object Ops extends Enumeration { val Create = Value("create") val Delete = Value("delete") } Then, I create an Ops from a String: val op = Ops.valueOf("create") Inside my match, I have: case (Ops.Create, ...) But Ops.Create doesn't seem to equal ops.valueOf("create") The former is just an atom 'create' and the later is Some(create) Hopefully, this is enough info for someone to tell me what I'm missing... Thanks

    Read the article

  • checking boolean property in XML(Spring)

    - by Abhishek Bhandari
    I am using Spring Framework . While writing coustum SQL queries , i am unable check a parameter of boolean value. For example this is not working .. do some SQl cods The above checking is not working , it is evaluating as equal in both the cases when booleanVariable is true and false . i tried to replace compareValue ="tree" and "false". As that is a monkey work i do sometimes . is it possible to check the boolean property in XML like above .

    Read the article

  • linux's fork and system resources

    - by Dmitry Bespalov
    Suppose I have following code in linux: int main() { FILE* f = fopen("file.txt", "w"); fork(); fwrite("A", 1, 1, f); fclose(f); return 0; } What I know about fork from documentation, is that it makes the copy of current process. It copies state of the memory as well, so *f should be equal in both instances. But what happens with system resources, such as a file handle? In this example I open the file with write intentions, so only one instance can write into file, right? Which of the instances will actually write into file? Who should care further about the file handle, and call fclose() ?

    Read the article

  • How do I prevent a pair of XMLEvent[Reader|Writer] from splitting empty tags into start+end tags?

    - by java.is.for.desktop
    Hello, everyone! I have an understanding problem of how the following code works: XMLInputFactory xif = XMLInputFactory.newFactory(); XMLOutputFactory xof = XMLOutputFactory.newFactory(); XMLEventReader reader = xif.createXMLEventReader(/* ... */); XMLEventWriter writer = xof.createXMLEventWriter(/* ... */); writer.add(reader); The method writer.add([some reader]) reads all events from reader and writes them consequently. Sadly, following happens: The input <root><c/></root> gets transformed to <root><c><c/></root> I know, from XML point of view, these are equal trees, but not for a human ;) What can I do to get the same output? FYI: I need a XMLEvent[Reader|Writer] pair later to filter "XML events".

    Read the article

  • C++ integer floor function

    - by Thomas
    I want to implement greatest integer function. int x = 5/3; My question is with greater numbers could there be a loss of precision as 5/3 would produce a double? EDIT: Greatest integer function is integer less than or equal to X. Example: 4.5 = 4 4 = 4 3.2 = 3 3 = 3 What I want to know is 5/3 going to produce a double? Because if so I will have loss of precision when converting to int. Hope this makes sense. RE-EDIT: What OP calls 'greatest integer' most of us call 'floor'.

    Read the article

  • How to test if a string is inside a list of predinfined list of string in oracle pl/sql

    - by drupalspring
    I define a list a string which contains different country codes ( for example , USA ,CHINA ,HK ,JPN) How can I check that if a input variable equal to one of the country of the country list in pl/sql . I use the following code to test it but fail, how can I revise it? declare country_list CONSTANT VARCHAR2(200) := USA,CHINA,HK,JPN; input VARCHAR2(200); begin input := 'JPN'; IF input IN (country_list) DBMS_OUTPUT.PUT_LINE('It is Inside'); else DBMS_OUTPUT.PUT_LINE('It is not Inside'); END IF; end;

    Read the article

  • Byte order (endian) of int in NSLog?

    - by Eonil
    NSLog function accepts printf format specifiers. My question is about %x specifier. Does this print hex codes as sequence on memory? Or does it have it's own printing sequence style? unsigned int a = 0x000000FF; NSLog(@"%x", a); Results of above code on little or big endian processors are equal or different? And how about NSString's -initWithFormat method? Does it follows this rule equally?

    Read the article

  • DJANGO complex modelling

    - by SledgehammerPL
    Hello. I have such model now: receipt contains components. component contain product. The difference between component and product is, that component has quantity and measure unit: eg. component is 100g sugar - sugar is a product. So I need to make lots of components to satisfy different recipes - 100g sugar is not equal 200g sugar I wonder if I can remodel it to kick off components - in pure sql it's rather easy, but I'm trying to USE django - not making workarounds. class Receipt(models.Model): name = models.CharField(max_length=128) (...) components = models.ManyToManyField(Component) class Component(models.Model): quantity = models.FloatField(max_length=9) unit = models.ForeignKey(Unit) product = models.ForeignKey(Product) class Product(models.Model): name = models.CharField(max_length = 128) TIA

    Read the article

  • I need to do a BASICE For Loop algorithm for a java Pyramid

    - by user1665119
    Question 2. USE THE FOR LOOP. Design and write an algorithm that will read a single positive number from the keyboard and will then print a pyramid out on the screen. The pyramid will need to be of a height equal in lines to the number inputted by the operator. Your program is not to test for negative numbers, nor is it to cater for them. For your test, use the number 7. If you would like to take the problem further, try 18 and watch what happens. Example input: 4 Example output: 1 121 12321 1234321

    Read the article

  • Creating a pie chart for an app

    - by jhodgson4
    I'm developing an app which requires a pie chart to display a set number of modules. The modules need to be clickable, sending a value to the database for how many times the module has been clicked. The slices will change color etc depending on this database value. The slices will always be equal in size. All simple stuff. My question is what charting system would you use. I've been looking at google charts but I have no way of registering a value in a slice without changing its 'weight' in the chart. So ideally I would like to add data-stage="2" to each slice that I can access with a custom method. Also google charts seems quite heavy for what I need? Any advice would be greatly appreciated. Joe

    Read the article

  • What is the effect on record size of reordering columns in PostgreSQL?

    - by Summer
    Since Postgres can only add columns at the end of tables, I end up re-ordering by adding new columns at the end of the table, setting them equal to existing columns, and then dropping the original columns. So, what does PostgreSQL do with the memory that's freed by dropped columns? Does it automatically re-use the memory, so a single record consumes the same amount of space as it did before? But that would require a re-write of the whole table, so to avoid that, does it just keep a bunch of blank space around in each record? Thanks! ~S

    Read the article

  • Python 3: Most efficient way to create a [func(i) for i in range(N)] list comprehension

    - by mejiwa
    Say I have a function func(i) that creates an object for an integer i, and N is some nonnegative integer. Then what's the fastest way to create a list (not a range) equal to this list mylist = [func(i) for i in range(N)] without resorting to advanced methods like creating a function in C? My main concern with the above list comprehension is that I'm not sure if python knows beforehand the length of range(N) to preallocate mylist, and therefore has to incrementally reallocate the list. Is that the case or is python clever enough to allocate mylist to length N first and then compute it's elements? If not, what's the best way to create mylist? Maybe this? mylist = [None]*N for i in range(N): mylist[i] = func(i)

    Read the article

  • generate an array from an array with conditions

    - by Aman
    Suppose i have an array $x = (31,12,13,25,18,10); I want to reduce this array in such a way that the value of each array element is 32. so after work my array will become $newx = (32,32,32,13); I have to generate this array in such a way the sum of array values is never greater than 32. so to create first value, i will reduce 1 from second index value i.e. 12, so the second value will become 11 and first index value will become 31+1 =32. This process should continue so that each array value becomes equal to 32.

    Read the article

  • Using Closure Properties to prove Regularity

    - by WATWF
    Here's a homework problem: Is L_4 Regular? Let L_4 = L*, where L={0^i1^i | i>=1}. I know L is non-regular and I know that Kleene Star is a closed operation, so my assumption is that L_4 is non-regular. However my professor provided an example of the above in which L = {0^p | p is prime}, which he said was regular by proving that L* was equal to L(000* + e) by saying each was a subset of one another (e in this case means the empty word). So his method involved forming a regex of 0^p, but how I can do that when I essentially have one already?

    Read the article

  • Finding the next record in the database with Active Record

    - by ericraio
    So I have my rails application and I have blog posts in my application. For starters I am on rails 2.3.5 and Ruby 1.8.7 For the show page, I am required to give a prev/next link to the prev/next blog post. The catch is that I need to find the next blog where the language column in the database is equal to 'eng'. I had started writing this out in my model and it works but of course this will just find the prev/next record in the database no matter what the language is specified in the column and it will break when the record is not found. def next(lang='eng') BlogEntry.find(self.id - 1) end def prev(lang='eng') BlogEntry.find(self.id + 1) end

    Read the article

  • write() in sys/uio.h returns -1

    - by fredrik
    I'm using Ubuntu Server 9.10 AMD Phenom 2 cpu g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1 trying to run the application pftp-shit v 1.11. The following code in tcp.cc is executed successfully: int outfile_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY)) which returns a file descriptor int (in my case 6) - name is a char array containing a valid path to my file which successfully i created. and successfully running: fchmod(outfile_fd, S_IRUSR | S_IWUSR); and access(name, W_OK) The issue occurs during running the function (from sys/uio.h) write(outfile_fd, this-control_buffer, read_length) which returns -1. -1 is of returned if nothing was written and otherwise a non-negative integer is returned which is equal to the number of bytes written. Anyone having a clue how I can get the write function to work?

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >