comparison

How to compare two floating-point values in shell script

I had to do a division in shell script and the best way was: result1=`echo "scale=3; ($var1 / $total) * 100"| bc -l` result2=`echo "scale=3; ($var2 / $total) * 100"| bc -l` but I want to compare the values of $result1 and $result2 Using if test $result1 -lt $result2 or if [ $result1 -gt $result2 ] didn't work :( Any idea how to do t...

heterogeneous comparisons in python3

I'm 99+% still using python 2.x, but I'm trying to think ahead to the day when I switch. So, I know that using comparison operators (less/greater than, or equal to) on heterogeneous types that don't have a natural ordering is no longer supported in python3.x -- instead of some consistent (but arbitrary) result we raise TypeError instead...

Generate a collection of changed lines between two revisions of a file using Java

I am writing an eclipse plugin which needs to be able to determine which lines of a file have changed compared to a different version of the same file. Is there an existing class or library which I can use for this task? The closest I have found is org.eclipse.compare.internal.merge.DocumentMerger. This can be used to find the informat...

What is the easiest straightforward way of telling which version performs better?

I have an application, which I have re-factored so that I believe it is now faster. One can't possibly feel the difference, but in theory, the application should run faster. Normally I would not care, but as this is part of my project for my master's degree, I would like to support my claim that the re-factoring did not only lead to impr...

.NET: Strange behaviour of double.Equals() when boxing.

What's going on here? int zero = 0; double x = 0; object y = x; Console.WriteLine(x.Equals(zero)); // True Console.WriteLine(y.Equals(zero)); // False ...

Comparing values longitudinally in R... with a twist

I have the results of a test taken by a number of individuals at as many as four time periods. Here's a sample: dat <- structure(list(Participant_ID = c("A", "A", "A", "A", "B", "B", "B", "B", "C", "C", "C", "C"), phase = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("base", "sixmos", "twelvemos", "eighteen...

Getting an exception when trying to use extension method with SortedDictionary... why?

I'm trying to place custom objects into a sorted dictionary... I am then trying to use an extension method (Max()) on this sorted dictionary. However, I'm getting the exception: "At least one object must implement IComparable". I don't understand why I'm getting that, as my custom object obviously implements IComparable. Here is my c...

Determining whether a file is a duplicate

Is there a reliable way to determine whether or not two files are the same? For example, two files with the same size and type may or may not be the same binarilly (yeah, I know it's not really a word). I assume that comparing one or two checksums of the files will help, but I wonder: How reliable are checksums at determining whether t...

C#, Fastest (Best?) Method of Identifying Duplicate Files in an Array of Directories

I want to recurse several directories and find duplicate files between the n number of directories. My knee-jerk idea at this is to have a global hashtable or some other data structure to hold each file I find; then check each subsequent file to determine if it's in the "master" list of files. Obviously, I don't think this would be ve...

How to compare 2 objects for equality in Objective-C

In Java you can write an if statement like this: if(object1.equals(object2)){ // Do something.... } How can I code the same logic in Objective-C? I basically want to compare 2 of any one type of objects, such as 'Text Fields', 'Text Views', etc. Thank you. Shakeel ...

Comparison of music data

Hey I am looking for theory, algorithms and similar for how to compare music. More specifically, I am looking into how to dupecheck music tracks that have different bitrates or perhaps slightly different variations (radio vs album version), but otherwise sound the same. Use cases for this include services such as Grooveshark, Youtube, ...

Comparing objects and inheritance

Hi, In my program I have the following class hierarchy: class Base // Base is an abstract class { }; class A : public Base { }; class B : public Base { }; I would like to do the following: foo(const Base& one, const Base& two) { if (one == two) { // Do something } else { // Do something else } } I have issues ...

Quickest way to compare a bunch of array or list of values.

Can you please let me know on the quickest and efficient way to compare a large set of values. Its like there are a list of parent codes(string) and each code has a series of child values(string). The child lists have to be compared with each other and find out duplicates and count how many times they repeat. code1(code1_value1, code1_v...

JavaScript date comparisons

I am new to the lower level useful functions of JavaScript, and I find myself needing to compare two date objects, but within an hourly range. For example, if Date1 is less then two hours until (or from) Date2. How could this be done? ...

Search object array for matching possible multiple values using different comparison operators

I have a function to search an array of objects for a matching value using the eq operator, like so: sub find { my ( $self, %params ) = @_; my @entries = @{ $self->{_entries} }; if ( $params{filename} ) { @entries = grep { $_->filename eq $params{filename} } @entries; } if ( $params{date} ) { @entrie...

Is it guaranteed that new Integer(i) == i in Java?

Consider the following snippet: int i = 99999999; byte b = 99; short s = 9999; Integer ii = Integer.valueOf(9); // should be within cache System.out.println(new Integer(i) == i); // "true" System.out.println(new Integer(b) == b); // "true" System.out.println(new Integer(s) == s); // "true" System.out.pri...

How can I use Perl to determine whether the contents of two files are identical?

This question comes from a need to ensure that changes I've made to code doesn't affect the values it outputs to text file. Ideally, I'd roll a sub to take in two filenames and return 1or return 0 depending on whether the contents are identical or not, whitespaces and all. Given that text-processing is Perl's forté, it should be quite e...

How can I check if a Perl array contains a particular value?

I am trying to figure out a way of checking for the existence of a value in an array without iterating through the array. I am reading a file for a parameter. I have a long list of parameters I do not want to deal with. I placed these unwanted parameters in an array @badparams. I want to read a new parameter and if it does not exist i...

comparing salt and hashed passwords during login doesn't seem work right....

I stored salt and hash values of password during user registration... But during their login i then salt and hash the password given by the user, what happens is a new salt and a new hash is generated.... string password = collection["Password"]; reg.PasswordSalt = CreateSalt(6); reg.PasswordHash = CreatePasswordHash(password, reg.Pass...

C# Possible unintended reference comparison...

When i try to check Session["userId"] != null why i get this message Possible unintended reference comparrison; to get value comparrison; cast left hand side to string Any suggestion.... ...