Search Results

Search found 2896 results on 116 pages for 'comparison operators'.

Page 16/116 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • compare windows server for patch/update/hotfix installs

    - by user12002221
    Are there any tools that can be used to connect to windows 2008 servers, and get a comparison of the installed patches/updates on the servers, showing what is installed on one and not on the other? This is to help isolate an issue we are seeing on a specific windows server, in a load balanced setup. There is a certain performance/locking issue, which is mitigated whenever one of the servers is disabled. Please share, if you have any suggestions. Thanks in advance!

    Read the article

  • DWORD to bytes using bitwise shift operators

    - by Dave18
    I can't get it to work correctly. #include <windows.h> int main() { DWORD i = 6521; BYTE first = i >> 32; BYTE second = i >> 24; BYTE third = i >> 16; BYTE fourth = i >> 8; i = (((DWORD)fourth) << 24) | (((DWORD)third) << 16) | (((DWORD)second) << 8) | first; }

    Read the article

  • Evaluation of (de)reference operators

    - by Micha
    I have an (uncommented...) source file which I'm trying to understand. static const Map *gCurMap; static std::vector<Map> mapVec; then auto e = mapVec.end(); auto i = mapVec.begin(); while(i!=e) { // ... const Map *map = gCurMap = &(*(i++)); // ... } I don't understand what &(*(i++)) does. It does not compile when just using i++, but to me it looks the same, because I'm "incrementing" i, then I'm requesting the value at the given address and then I'm requesting the address of this value?!

    Read the article

  • Using enum values to represent binary operators (or functions)

    - by Bears will eat you
    I'm looking for an elegant way to use values in a Java enum to represent operations or functions. My guess is, since this is Java, there just isn't going to be a nice way to do it, but here goes anyway. My enum looks something like this: public enum Operator { LT, LTEQ, EQEQ, GT, GTEQ, NEQ; ... } where LT means < (less than), LTEQ means <= (less than or equal to), etc - you get the idea. Now I want to actually use these enum values to apply an operator. I know I could do this just using a whole bunch of if-statements, but that's the ugly, OO way, e.g.: int a = ..., b = ...; Operator foo = ...; // one of the enum values if (foo == Operator.LT) { return a < b; } else if (foo == Operator.LTEQ) { return a <= b; } else if ... // etc What I'd like to be able to do is cut out this structure and use some sort of first-class function or even polymorphism, but I'm not really sure how. Something like: int a = ..., b = ...; Operator foo = ...; return foo.apply(a, b); or even int a = ..., b = ...; Operator foo = ...; return a foo.convertToOperator() b; But as far as I've seen, I don't think it's possible to return an operator or function (at least, not without using some 3rd-party library). Any suggestions?

    Read the article

  • Ternary operators in C#

    - by pm_2
    With the ternary operator, it is possible to do something like the following (assuming Func1() and Func2() return an int: int x = (x == y) ? Func1() : Func2(); However, is there any way to do the same thing, without returning a value? For example, something like (assuming Func1() and Func2() return void): (x == y) ? Func1() : Func2(); I realise this could be accomplished using an if statement, I just wondered if there was a way to do it like this.

    Read the article

  • Looking for merge tool with very good in-line-comparison support

    - by peter p
    I have seen this topic discussed several times, but emphasis is on "very good in-line-comparison" here, which was not really covered by those threads. E.g. I would like the tool to recognize and highlight that the resource "colorpicker_newstring" has been added when comparing the following two blocks. WinMerge and Kdiff both fail... Does anyone know a software that does not? I am using Windows. Ah, and I'd prefer free/OS software, of course. Thanks a lot in advance, Peter File A: <resource name="colorpicker_title">Color picker</resource> <resource name="colorpicker_apply">Apply</resource> <resource name="colorpicker_transparent">Transparent</resource> <resource name="colorpicker_htmlcolor">HTML color</resource> <resource name="colorpicker_red">Red</resource> <resource name="colorpicker_newstring">New String</resource> <resource name="colorpicker_green">Green</resource> <resource name="colorpicker_blue">Blue</resource> <resource name="colorpicker_alpha">Alpha</resource> <resource name="colorpicker_recentcolors">Recently used colors</resource> File B: <resource name="colorpicker_title">Sélecteur de couleur</resource> <resource name="colorpicker_apply">Appliquer</resource> <resource name="colorpicker_transparent">Transparent</resource> <resource name="colorpicker_htmlcolor">Couleur HTML</resource> <resource name="colorpicker_red">Rouge</resource> <resource name="colorpicker_green">Vert</resource> <resource name="colorpicker_blue">Bleu</resource> <resource name="colorpicker_alpha">Alpha</resource> <resource name="colorpicker_recentcolors">Couleurs récentes</resource>

    Read the article

  • convert htmlelement to string for comparison javascript

    - by Jamex
    Hi, I am using a function that obtains a target element id at onclick. Example, if I click on the text element that has the id of 'help'. var click = (e && e.target) || (event && event.srcElement); The var click would contain the ref to the id of "help". I want to compare the var click to the string 'help' using the if statement below. if (click == 'about') {do something} The comparison does not work because the var click is not a string. When I use the alert(click) to debug, it shows click as "object HTMLElement". How would you compare whether the id 'help' is obtained from var click? I could write out something like if (click == document.getElementById('help')) {do something} but that would make a long statement. also if the var click is document.getElementById('help'), how would you make a new var "show" as document.getElementById('showhelp') basically, I want to use the same function to generate dynamic responses to each element that was clicked on, and not having to create a separate function for each element.

    Read the article

  • Draw a comparison between an integer in a specific row and a count

    - by XCoderX
    This is a follow-up question to this one: Check for specific integer in a row WHERE user = $name I want a user to be able to comment on my site for exactly five times a day. After this five times, the user has to wait 24 hours. In order to accomplish that I raise a counter in my MYSQL database, right next to the user. So where the name of the user is, there is where the counter gets raised. When it reaches 5 it should stop counting and reset after 24 hours. In order to check the time I use a timestamp. I check if the timestamp is older than 24 hours. If that is the case, the counter gets reseted (-5) and the user can comment again. In order to do that, I use the following code, however it never stops at five, my guess is that my comparison is wrong somehow: $counter = "SELECT FROM table VALUES CommentCounterReset WHERE Name = '$name'"; if(!isset($_SESSION['ts'])); { $_SESSION['ts'] = time(); } if ($counter >= 5) { if (time() - $_SESSION['ts'] <= 60*60*24){ echo "You already wrote five comments."; } else { $sql = "UPDATE table SET CommentCounterReset = CommentCounterReset-5 WHERE Name = '$name'"; } } else { $sql = "UPDATE table SET CommentCounterReset = CommentCounterReset+1 WHERE Name = '$name'"; echo "Your comment has been added."; }

    Read the article

  • C++ segmentation error when first parameter is null in comparison operator overload

    - by user1774515
    I am writing a class called Word, that handles a c string and overloads the <, , <=, = operators. word.h: friend bool operator<(const Word &a, const Word &b); word.cc: bool operator<(const Word &a, const Word &b) { if(a == NULL && b == NULL) return false; if(a == NULL) return true; if(b == NULL) return false; return a.wd < b.wd; //wd is a valid c string } main: char* temp = NULL; //EDIT: i was mistaken, temp is a char pointer Word a("blah"); //a.wd = [b,l,a,h] cout << (temp<a); i get a segmentation error before the first line of the operator< method after the last line in the main. I can correct the problem by writing cout << (a>temp); where the operator> is similarly defined and i get no errors. but my assignment requires (temp < a) to work so this is where i ask for help. EDIT: i made a mistake the first time and i said temp was of type Word, but it is actually of type char*. so i assume that the compiler converts temp to a Word using one of my constructors. i dont know which one it would use and why this would work since the first parameter is not Word. here is the constructor i think is being used to make the Word using temp: Word::Word(char* c, char* delimeters=NULL) { char *temporary = "\0"; if(c == NULL) c = temporary; check(stoppers!=NULL, "(Word(char*,char*))NULL pointer"); //exits the program if the expression is false if(strlen(c) == 0) size = DEFAULT_SIZE; //10 else size = strlen(c) + 1 + DEFAULT_SIZE; wd = new char[size]; check(wd!=NULL, "Word(char*,char*))heap overflow"); delimiters = new char[strlen(stoppers) + 1]; //EDIT: changed to [] check(delimiters!=NULL,"Word(char*,char*))heap overflow"); strcpy(wd,c); strcpy(delimiters,stoppers); count = strlen(wd); } wd is of type char* thanks for looking at this big question and trying to help. let me know if you need more code to look at

    Read the article

  • how to refer to the current struct in an overloaded operator?

    - by genesys
    Hi! I have a struct for which i want to define a relative order by defining < , , <= and = operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger. I defined the first operator like this: struct MyStruct{ ... ... bool operator < (const MyStruct &b) const {return (somefancycomputation);} }; now i'd like to define the other operators based on this operator, such that <= will return the same as < and the other two will simply return the oposite. so for example for the operator i'd like to write something like bool operator > (const MyStruct &b) const {return !(self<b);} but i don't know how to refere to this 'self' since i can refere only to the fields inside the current struct. whole is in C++ hope my question was understandable :) thank you for the help!

    Read the article

  • File sorting, Comparison method violates its general contract

    - by user2677383
    My file sorting comparator sometimes invoke java.lang.IllegalArgumentException in android app. I cannot figure out the reason. could you explain that? here is my code block: Comparator cc = new Comparator<File>() { @Override public int compare(File f1, File f2) { if (f1.isDirectory() && !f2.isDirectory()) { return 1; } if (f2.isDirectory() && !f1.isDirectory()) { return -1; } if ((f1.isFile() && f2.isFile()) || (f1.isDirectory() && f2.isDirectory())) { if (sort == 1) { return Util.compareFileName(f2.getName(), f1.getName()); } else if (sort == 2) { return (int) (f1.lastModified() - f2.lastModified()); } else if (sort == 3) { return (int) (f2.lastModified() - f1.lastModified()); } else if (sort == 4) { return (int) (f1.length() - f2.length()); } else if (sort == 5) { return (int) (f2.length() - f1.length()); } else return Util.compareFileName(f1.getName(), f2.getName()); } return f1.compareTo(f2); } }; Util.compareFileName is as followings: public static int compareFileName(String s1, String s2) { int thisMarker = 0; int thatMarker = 0; int s1Length = s1.length(); int s2Length = s2.length(); while (thisMarker < s1Length && thatMarker < s2Length) { String thisChunk = getChunk(s1, s1Length, thisMarker); thisMarker += thisChunk.length(); String thatChunk = getChunk(s2, s2Length, thatMarker); thatMarker += thatChunk.length(); // If both chunks contain numeric characters, sort them numerically int result = 0; if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { // Simple chunk comparison by length. int thisChunkLength = thisChunk.length(); result = thisChunkLength - thatChunk.length(); // If equal, the first different number counts if (result == 0) { for (int i = 0; i < thisChunkLength; i++) { result = thisChunk.charAt(i) - thatChunk.charAt(i); if (result != 0) { return result; } } } } else { result = thisChunk.compareTo(thatChunk); } if (result != 0) return result; } return s1Length - s2Length; }

    Read the article

  • Deriving an HTMLElement Object from jQuery Object

    - by Jasconius
    I'm doing a fairly exhaustive series of DOM manipulations where a few elements (specifically form elements) have some events. I am dynamically creating (actually cloning from a source element) several boxes and assigning a change() event to them. The change event executes, and within the context of the event, "this" is the HTML Element Object. What I need to do at this point however is determine a contact for this HTML Element Object. I have these objects stored already as jQuery entities in assorted arrays, but obviously [HTMLElement Object] != [Object Object] And the trick is that I cannot cast $(this) and make a valid comparison since that would create a new object and the pointer would be different. So... I've been banging my head against this for a while. In the past I've been able to circumvent this problem by doing an innerHTML comparison, but in this case the objects I am comparing are 100% identical, just there's lots of them. Therefore I need a solid comparison. This would be easy if I could somehow derive the HTMLElement object from my originating jQuery object. Thoughts, other ideas? Help. :(

    Read the article

  • Warning: comparison with string literals results in unspecified behaviour

    - by nunos
    So I starting the project of writing a simplified sheel for linux in c. I am not at all proficient with c nor with Linux that's exactly the reason I decided it would be a good idea. Starting with the parser, I have already encountered some problems. The code should be straightforward that's why I didn't include any comments. I am getting a warning with gcc: "comparison with string literals results in unspecified behaviour" at the lines commented with "WARNING HERE" (see code below). I have no idea why this causes an warning, but the real problem is that even though I am comparing an "<" to an "<" is doesn't get inside the if... I am looking for an answer for the problem explained, however if there's something that you see in the code that should be improved please say so. Just take in mind I am not that proficient and that this is still a work in progress (or better yet, a work in start). Thanks in advance. #include <stdio.h> #include <unistd.h> #include <string.h> typedef enum {false, true} bool; typedef struct { char **arg; char *infile; char *outfile; int background; } Command_Info; int parse_cmd(char *cmd_line, Command_Info *cmd_info) { char *arg; char *args[100]; int i = 0; arg = strtok(cmd_line, " \n"); while (arg != NULL) { args[i] = arg; arg = strtok(NULL, " \n"); i++; } int num_elems = i; cmd_info->infile = NULL; cmd_info->outfile = NULL; cmd_info->background = 0; int iarg = 0; for (i = 0; i < num_elems; i++) { if (args[i] == "&") //WARNING HERE return -1; else if (args[i] == "<") //WARNING HERE if (args[i+1] != NULL) cmd_info->infile = args[i+1]; else return -1; else if (args[i] == ">") //WARNING HERE if (args[i+1] != NULL) cmd_info->outfile = args[i+1]; else return -1; else cmd_info->arg[iarg++] = args[i]; } cmd_info->arg[iarg] = NULL; return 0; } void print_cmd(Command_Info *cmd_info) { int i; for (i = 0; cmd_info->arg[i] != NULL; i++) printf("arg[%d]=\"%s\"\n", i, cmd_info->arg[i]); printf("arg[%d]=\"%s\"\n", i, cmd_info->arg[i]); printf("infile=\"%s\"\n", cmd_info->infile); printf("outfile=\"%s\"\n", cmd_info->outfile); printf("background=\"%d\"\n", cmd_info->background); } int main(int argc, char* argv[]) { char cmd_line[100]; Command_Info cmd_info; printf(">>> "); fgets(cmd_line, 100, stdin); parse_cmd(cmd_line, &cmd_info); print_cmd(&cmd_info); return 0; }

    Read the article

  • Which e-reader for O'Reilly books?

    - by Tim
    Most of my programming books are from O'Reilly. Several of them need to be updated, and I'm thinking of going for an e-reader this time. O'Reilly sell their e-books as a multi-format bundle (PDF, EPUB and Mobipocket (Kindle)). Has anyone done a comparison of the formats as for suitability on a small e-reader screen? In Europe, the Kindle DX is not (yet?) available, so I'm not sure whether a Kindle or a Sony (or some other reader) is best suited for these books. Disregarding other advantages/disadvantages of the different readers for now, which one in your opinion gives the best experience with O'Reilly books in particular (or programming books in general)?

    Read the article

  • Which one is better deal: iPed or Apple iPad?

    - by Evan Carroll
    The Chinese knockoff iPed is now in the wild and receiving a lot of attention? Does anyone know how the Android distribution it ships with compares with Apple iPad's software pack? How does the look-and-feel of the iPed fit with the Apple iPad? Quite frankly, I have little interest in Apple products because of the company policy. But, cheaper comparable hardware running open-source software is pretty interesting... Anything useful to add.. Here are the Apple iPad specs for comparison. The iPed is priced at $199.00, the Apple iPad starts at $499.00 .

    Read the article

  • compareTo() method java is acting weird

    - by Ron Paul
    hi im having trouble getting this to work im getting an error here with my object comparison...how could I cast the inches to a string ( i never used compare to with anything other than strings) , or use comparison operators to compare the intigers, Object comparison = this.inches.compareTo(obj.inches); here is my code so far import java.io.*; import java.util.*; import java.lang.Integer; import java.lang.reflect.Array; public class Distance implements Comparable<Distance> { private static final String HashCodeUtil = null; private int feet; private int inches; private final int DEFAULT_FT = 1; private final int DEFAULT_IN = 1; public Distance(){ feet = DEFAULT_FT; inches = DEFAULT_IN; } public Distance(int ft, int in){ feet = ft; inches = in; } public void setFeet(int ft){ try { if(ft<0){ throw new CustomException("Distance is not negative"); } } catch(CustomException c){ System.err.println(c); feet =ft; } } public int getFeet(){ return feet; } public void setInches(int in){ try { if (in<0) throw new CustomException("Distance is not negative"); //inches = in; } catch(CustomException c) { System.err.println(c); inches = in; } } public int getInches(){ return inches; } public String toString (){ return "<" + feet + ":" + inches + ">"; } public Distance add(Distance m){ Distance n = new Distance(); n.inches = this.inches + m.inches; n.feet = this.feet + m.feet; while(n.inches>12){ n.inches = n.inches - 12; n.feet++; } return n; } public Distance subtract(Distance f){ Distance m = new Distance(); m.inches = this.inches - f.inches; m.feet = this.feet - f.feet; while(m.inches<0){ m.inches = m.inches - 12; feet--; } return m; } @Override public int compareTo(Distance obj) { // TODO Auto-generated method stub final int BEFORE = -1; final int EQUAL = 0; final int AFTER = 1; if (this == obj) return EQUAL; if(this.DEFAULT_IN < obj.DEFAULT_FT) return BEFORE; if(this.DEFAULT_IN > obj.DEFAULT_FT) return AFTER; Object comparison = this.inches.compareTo(obj.inches); if (this.inches == obj.inches) return compareTo(null); assert this.equals(obj) : "compareTo inconsistent with equals"; return EQUAL; } @Override public boolean equals( Object obj){ if (obj != null) return false; if (!(obj intanceof Distance)) return false; Distance that = (Distance)obj; ( this.feet == that.feet && this.inches == that.inches); return true; else return false; } @Override public int hashCode(int, int) { int result = HashCodeUtil.inches; result = HashCodeUtil.hash(result, inches ); result = HashCodeUtil.hash(result, feet); ruturn result; }

    Read the article

  • Java operator precedence guidelines

    - by trashgod
    Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here are a number of resources on the topic: JLS Operators JLS Precedence Java Glossary Princeton Sun Tutorial University of West Florida Usenet discussion Additions or corrections welcome.

    Read the article

  • How to use ternary operator instead of if-else in PHP

    - by Mac Taylor
    hey guys i need to shorten or better to say ., harden my codes this is my original code : if ($type = "recent") { $OrderType = "sid DESC"; }elseif ($type = "pop"){ $OrderType = "counter DESC"; }else { $OrderType = "RAND()"; } now how can i use markers like this : $OrderType = ($type = "recent") ? "sid DESC" : "counter DESC" ; i tried but i didnt know how to write elseif in operators

    Read the article

  • Perl ||= operator for PHP and Javascript

    - by zaf
    Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example: keys my %or_cache = @in; @out = sort { ($or_cache{$a} ||= KEY($a)) cmp ($or_cache{$b} ||= KEY($b)) } @in; Is this operator available in PHP and Javascript? And if not, do these two languages allow user defined operators?

    Read the article

  • 'AND' vs '&&' as operator

    - by ts
    Actually, i am facing a codebase where developpers decided to use 'AND' and 'OR' instead of '&&' and '||'. I know that there is difference in operators precedence (&& goes before 'and'), but with given framework (prestashop to be precise) is clearly not a reason. So, my question: which version are you using? Is 'and' more readable than '&&'? || there is ~ difference?

    Read the article

  • Are +=, |=, &= etc atomic?

    - by SF.
    Are the "modify" operators like +=, |=, &= etc atomic? I know ++ is atomic (if you perform x++; in two different threads "simultaneously", you will always end up with x increased by 2, as opposed to x=x+1 with optimization switched off.) What I wonder is whether variable |= constant, and the likes are thread-safe or do I have to protect them with a mutex? (...or is it CPU-dependent? In this case, how is it on ARM?)

    Read the article

  • In what situation should the built-in 'operator' module be used in python?

    - by apphacker
    I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a set of functions implemented in C corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. The function names are those used for special class methods; variants without leading and trailing __ are also provided for convenience. I'm not sure I understand the benefit or purpose of this module.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >