comparing

Is it correct to compare two rounded floating point numbers using the == operator?

Or is there a chance that the operation will fail? Thanks. I chose the wrong term and what I really meant was rounding to 0, not truncation. The point is, I need to compare the integer part of two doubles and I'm just casting them to int and then using ==, but, as someone pointed out in one of my earlier questions, this could throw an...

Comparing 2 huge lists using C# multiple times (with a twist)

Hey everyone, great community you got here. I'm an Electrical Engineer doing some "programming" work on the side to help pay for bills. I say this because I want you to take into consideration that I don't have proper Computer Science training, but I have been coding for the past 7 years. I have several excel tables with information (a...

comparing arrays in objective-c

Ok a pretty simple question.. in c++ it seems to work but in objective-c i seem to struggle with it :S .. If you want to compare two arrays it should be something like this right for ( int i = 0; i < [appdelegate.nicearray count]; i++ ) { if ( appdelegate.nicearray[i] == appdelegate.exercarray[i] ) { NSLog(@"the same elem...

comparing object attribute in one array to an object attribute in another array

Hello all ... i seem to be having difficulties in accessing and comparing objects in NSMutableArrays in objective c. I'm very new so when explaining , some code would be nice. I have a character class and a characterfound class. The code looks like this: @implementation character @synthesize IDE, name; - (void) dealloc { [text ...

How to do equality comparison in SQL with C#-like behavior?

How to compare equality of value in SQL with null? For those familiar with C#, here are the results of comparing nullable values: null == null : true null == john : false null == paul : false john == null : false john == john : true john == paul : false paul == null : false paul == john : false paul == paul : true The easiest solutio...

What is the best way of comparing a string variable to a set of string constants?

if statement looks too awkward, because i need a possibility to increase the number of constatnts. Sorry for leading you into delusion by that "constant" instead of what i meant. ...

Any existing php code out there for condorcet comparing?

I beleive the website 'whatsbetter.com' (defunct) used a Condorcet method for comparing two images such that they could join a list of ranked images, and also have data stored about their performance against each other over time. I would like to implement something like this myself. I don't want to over complicate it. My brain isn't g...

comparing a Node and an Object with a BST data structure

I'm getting a "java.lang.string cannot be cast to node" exception. I thought of converting the localRoot to a string using a provided toString method then comparing them, nut this leaves no concept of 'greater than' or 'less than' which I need to navigate the BST... int computeResult = ((Node<E>)o).compareTo(localRoot); where o is o...

Efficient way to compare two strings (ordering of characters irrelevant)

I am trying to come up with an algorithm to compare two strings. It would register a match any words that contain the same letters. For example rent and tern would be equivalent because they both contain the letters r,e,n,t. EDIT I apologize for being so vague. The comparison is going to be made on two sets of a few thousands of words h...

C# Comparing Two Custom Lists

I have run into a situation where I need to compare two different lists to each other and I am wondering what the best method is for doing this? I thought something like this would work but it doesn't and I can't figure out why. The Linq query is returning records it shouldn't. This is my first run at trying to figure something like t...

Checking an array of data for similar elements in C

Hi, I created an "address" structure. Each address (xx.yy.zz.mm) consists of an xx, yy, zz and mm element, all of which are ints. Each address also has a "name" element associated with it. I have an array of up to 100 addresses called "network". Here is an example of some elements in network: 186.88.1.21 Tyler 186.88.9.11 Bob 101.21.0...

DateTime question

Hi, I have 2 DateTime objects, which I save to a file after using the ToShortDateString() function; the strings look like "12/15/2009". I am stuck on this part now, I want to initialize DateTimeObject(s) with these strings so I can compare the timespan between the date dates. Any help appreciated. ...

comparing GIF images pixels

I need to compare 2 same-size, nearly identical images for exact differences in the RGBs of every pixel. I would like to find a tool that already does it... seems nowhere to be found on google, strangely. If I could even find a tool to print out the RGB values of every pixel I could compute it by hand (the images are small enough) or l...

Comparing chars in a character array with strcmp

I have read an xml file into a char [] and am trying to compare each element in that array with certain chars, such as "<" and ">". The char array "test" is just an array of one element and contains the character to be compared (i had to do it like this or the strcmp method would give me an error about converting char to cons char*). Ho...

Compare two schemas and update the old schema with the new columns of new schema

hello, I've an Oracle database with two schemas. One is old and another is new. I would like to update the old schema with the new columns of the new schema. I get the tables which have changes with the following query. select distinct table_name from ( select table_name,column_name from all_tab_cols where owner = 'SCHEMA_1' minus s...

How can I find out if two arguments are instances of the same, but unknown class?

Let us say we have a method which accepts two arguments o1 and o2 of type Object and returns a boolean value. I want this method to return true only when the arguments are instances of the same class, e.g.: foo(new Integer(4),new Integer(5)); Should return true, however: foo(new SomeClass(), new SubtypeSomeClass()); should return f...

UIWebView comparing current and defined URL's with a loop depending on result

I am trying to compare the current url in webView with a defined url say google.com so in theory.. NSURLRequest *currentRequest = [webView request]; NSURL *currentURL = [currentRequest URL]; would give us our current url... NSString *newurl = @"http://www.google.com"; this would give us the compared to defined url while (!cu...

Silverlight? WPF? or Windows Form?

After Silverlight 4.0 has been released with new WPF, I am kind of confused with these technologies: Silverlight? WPF? Windows Form? The main motive that we want to achieve for BIG business project is following: Performance Security And platform independent** If I consider all above three points then only Silverlight is the option a...

How do I compare between ByteString and ByteSymbol in squeak?

Hi, I want to execute the following code: methodName := thisContext sender method selector. aClass selectors do: [:current | current == methodName ifTrue: aBlock]. Although the strings are equal, it never steps into the "ifTrue", I've tried converting both of them to ByteArray\String and it steel didn't work. Any ideas of how to comp...

comparing Session value problem in php.

if ($_SESSION['user_email']!=$_SESSION['ship_user_email']) { $to= $_SESSION['ship_user_email']; mail($to,$subject,$mail_html,$headers); } there is problem in comparing values of both session. value is different but code not working. ...