compare

Compare two dates in Java

前提是你 提交于 2019-11-26 19:06:00
I need to compare two dates in java. I am using the code like this: Date questionDate = question.getStartDate(); Date today = new Date(); if(today.equals(questionDate)){ System.out.println("Both are equals"); } This is not working. The content of the variables is the following: questionDate contains 2010-06-30 00:31:40.0 today contains Wed Jun 30 01:41:25 IST 2010 How can I resolve this? Eric Hauser Date equality depends on the two dates being equal to the millisecond. Creating a new Date object using new Date() will never equal a date created in the past. Joda Time 's APIs simplify working

x86 assembler: floating point compare

旧街凉风 提交于 2019-11-26 18:59:00
As part of a compiler project I have to write GNU assembler code for x86 to compare floating point values. I have tried to find resources on how to do this online and from what I understand it works like this: Assuming the two values I want to compare are the only values on the floating point stack, then the fcomi instruction will compare the values and set the CPU-flags so that the je , jne , jl , ... instructions can be used. I'm asking because this only works sometimes. For example: .section .data msg: .ascii "Hallo\n\0" f1: .float 10.0 f2: .float 9.0 .globl main .type main, @function main:

Compare two CSV files and search for similar items

核能气质少年 提交于 2019-11-26 18:51:06
So I've got two CSV files that I'm trying to compare and get the results of the similar items. The first file, hosts.csv is shown below: Path Filename Size Signature C:\ a.txt 14kb 012345 D:\ b.txt 99kb 678910 C:\ c.txt 44kb 111213 The second file, masterlist.csv is shown below: Filename Signature b.txt 678910 x.txt 111213 b.txt 777777 c.txt 999999 As you can see the rows do not match up and the masterlist.csv is always larger than the hosts.csv file. The only portion that I'd like to search for is the Signature portion. I know this would look something like: hosts[3] == masterlist[1] I am

What is the difference between == and Equals() for primitives in C#?

被刻印的时光 ゝ 提交于 2019-11-26 18:43:39
问题 Consider this code: int age = 25; short newAge = 25; Console.WriteLine(age == newAge); //true Console.WriteLine(newAge.Equals(age)); //false Console.ReadLine(); Both int and short are primitive types, but a comparison with == returns true and a comparison with Equals returns false. Why? 回答1: Short answer: Equality is complicated. Detailed answer: Primitives types override the base object.Equals(object) and return true if the boxed object is of the same type and value. (Note that it will also

How does one compare one image to another to see if they are similar by a certain percentage, on the iPhone?

守給你的承諾、 提交于 2019-11-26 18:43:28
I basically want to take two images taken from the camera on the iPhone or iPad 2 and compare them to each other to see if they are pretty much the same. Obviously due to light etc the image will never be EXACTLY the same so I would like to check for around 90% compatibility. All the other questions like this that I saw on here were either not for iOS or were for locating objects in images. I just want to see if two images are similar. Thank you. aroth As a quick, simple algorithm, I'd suggest iterating through about 1% of the pixels in each image and either comparing them directly against

Compare version numbers without using split function

…衆ロ難τιáo~ 提交于 2019-11-26 18:42:32
How do I compare version numbers? For instance: x = 1.23.56.1487.5 y = 1.24.55.487.2 Can you use the Version class? http://msdn.microsoft.com/en-us/library/system.version.aspx It has an IComparable interface. Be aware this won't work with a 5-part version string like you've shown (is that really your version string?). Assuming your inputs are strings, here's a working sample with the normal .NET 4-part version string: static class Program { static void Main() { string v1 = "1.23.56.1487"; string v2 = "1.24.55.487"; var version1 = new Version(v1); var version2 = new Version(v2); var result =

一文掌握 Lambda 表达式

非 Y 不嫁゛ 提交于 2019-11-26 18:22:12
本文将介绍 Java 8 新增的 Lambda 表达式,包括 Lambda 表达式的常见用法以及方法引用的用法,并对 Lambda 表达式的原理进行分析,最后对 Lambda 表达式的优缺点进行一个总结。 1. 概述 Java 8 引入的 Lambda 表达式的主要作用就是简化部分的写法。 能够使用 Lambda 表达式的一个重要依据是必须有相应的 函数接口 。所谓函数接口,是指内部有且仅有一个抽象方法的接口。 Lambda 表达式的另一个依据是 类型推断机制 。在上下文信息足够的情况下,编译器可以推断出参数表的类型,而不需要显式指名。 2. 常见用法 2.1 无参函数的简写 无参函数就是没有参数的函数,例如 Runnable 接口的 run() 方法,其定义如下: @FunctionalInterface public interface Runnable { public abstract void run(); } 在 Java 7 及之前版本,我们一般可以这样使用: new Thread(new Runnable() { @Override public void run() { System.out.println("Hello"); System.out.println("Jimmy"); } }).start(); 从 Java 8 开始

strcmp equivelant for integers (intcmp) in PHP

混江龙づ霸主 提交于 2019-11-26 18:11:06
问题 So we got this function in PHP strcmp(string $1,string $2) // returns -1,0, or 1; We Do not however, have an intcmp(); So i created one: function intcmp($a,$b) { if((int)$a == (int)$b)return 0; if((int)$a > (int)$b)return 1; if((int)$a < (int)$b)return -1; } This just feels dirty. What do you all think? this is part of a class to sort Javascripts by an ordering value passed in. class JS { // array('order'=>0,'path'=>'/js/somefile.js','attr'=>array()); public $javascripts = array(); ... public

Tool for comparing 2 binary files in Windows [closed]

ε祈祈猫儿з 提交于 2019-11-26 17:56:36
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I need a tool to compare 2 binaries. The files are quite large. Some freeware or trial tools I found on the Internet are not convenient to use for large files. Can you recommend me some tools? 回答1: A few possibilities: VBinDiff (binary diff, designed for large files) WinDiff bsdiff HexCmp See also: https://web

detect differences between two strings with Javascript

孤街醉人 提交于 2019-11-26 17:46:16
问题 With Javascript, I want to check how many differences there are between two strings. Something like: var oldName = "Alec"; var newName = "Alexander"; var differences = getDifference(oldName, newName) // differences = 6 Any letters added to the name should count as one change per letter. Changing a letter should count as a change per letter. Swaping two letters should count as two changes as your really changing each leter. However, shifting a letter and inserting another should only count as