|
I'm writing a grep function in C++ (as a self assigned exercise - I realize this doesn't have the functionality of an actual grep feature) to take an original string and the search string you are looking for. In the code, I enter all the characters in...
Started by Hooked on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
J [sic! He....
For a really good time, have a look at the Boyer-Moore string matching algorithm and the Knuth-Pratt-Morris algorithm .
After all, at least in some senses, two strings can't be equal if they're not of equal length .
Nope, not bad form at all.
|
|
I want to compare xml document. some are 50k+. i'm comparing the OuterXml. is this efficient? is there more effient way?
Started by premium_mesg_dev on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Just comparing the textual representation of your XML will not yield valid results - check this out.
|
|
What is the best method for comparing IEEE floats and doubles for equality? I have heard of several methods, but I wanted to see what the community thought.
Started by Craig H on
, 17 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Bool is_nan(float f) { return (*reinterpret_cast<unsigned __int32*>(&f) & 0x7f8 ) == 0x7f8 && (*reinterpret_cast<unsigned __int32*>(&f) & 0x007 ) != 0; } bool is_finite(float f) { return... .
The best approach I think is to compare ULPs .
|
Ask your Facebook Friends
|
Given two instances of a class, is it a good and reliable practice to compare them by serializaing them first and then comparing byte arrays (or possibly hashes of arrays). These objects might have complex hierarchical properties but serialization should...
Started by Valentin Vasilyev on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
As straightforward as it might sound; if you're comparing totally arbitrary objects, then there's a pretty good.
|
|
Hi. It seems I can't compare 2 date values with time.
When I compare just date part - year, month and day - everything works fine. But when I add comparing times everything breaks down and not even month fits.
So what's some basic algorithm for comparing...
Started by mnn on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Etcetera....
If one is bigger than the other, that's the later date .
Compare the days.
If one is bigger than the other, that's the later date .
Compare the months.
If one is bigger than the other, that's the later date .
Compare the years.
|
|
Hi,
I'm doing some calculations of comparing two strings. In case I know they are same length, is it more expensive to call isprefix or If ("string"=="string") ?
Started by Skuta on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
I would expect no significant difference at the core, as IsPrefix is essentially:
public bool IsPrefix(string... .
Why not test? Easy enough to use the StopWatch class to compare, and include different length strings and different compare options.
|
|
When comparing for equality is it okay to use == ?
For example:
int a = 3; int b = 4;
If checking for equality should you use:
if (a == b) { . . . }
Would the situation change if floating point numbers were used?
Started by Brandon on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Notice that comparing a NaN value to anything (also another.
Using "<" and ">" at the same time to check equality on a int results the rounding errors screw up equality checks .
comparing ints, use ==.
|
|
When viewing files in a shelveset, I would like the option of comparing the files to my current local version. Unfortunately, the only options available are "With Unmodified", "With Workspace" (I guess this one would be the answer, if it wasn't disabled...
Started by danijels on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Although this isn't the ideal way to do it, depending on your comparison tool you may be... .
I don't think that it is possible to compare a shelved version with a local version in Visual Studio, however I'll be very happily corrected on the matter.
|
|
I want to select records from sqlite3 database by string matching. But if I use '=' in the where clause, I found that sqlite3 is case sensitive. Can anyone tell me how to use string comparing case-insensitive? Thank you very much!
Started by quantity on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
WHERE name LIKE 'someone'
(It's not the solution, but in some cases is very convenient)
"The LIKE operator... .
WHERE UPPER(name) = UPPER('someone')
You can do it like this:
SELECT * FROM .. .
This is not specific to sqlite but you can just do
SELECT * FROM .. .
|
|
'man uniq' documents the -f=N and -s=N options which make uniq skip the first N fields/characters respectively when comparing lines, but how would you force uniq to skip the last N fields/characters?
Started by Julius on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Rev $filename | sort | uniq -f=N | rev
you will need to sort your data first if you want to use uniq
sort file | rev | uniq -f 10 | rev .
|