Posts you want to find years later go here.
VLSmooth
Tenth Dan Procrastinator
Posts: 3055 Joined: Fri Jul 18, 2003 3:02 am
Location: Varies
Contact:
Post
by VLSmooth » Fri Mar 05, 2004 5:48 pm
Code: Select all
// debug: print out vector
for (vector<int>::iterator iter = someVector.begin();
iter != someOtherVector.end();
++iter) {
printf("%d\n", *iter);
}
Anyone see a problem? I feel extremely stupid right now... (took 2.5 days to track down...)
Example has been intentionally generalized with extra vagueness
Last edited by
VLSmooth on Fri Mar 05, 2004 5:58 pm, edited 1 time in total.
Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790 Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA
Post
by Peijen » Fri Mar 05, 2004 5:52 pm
I don't see what's wrong with the code, some time you need to know where the value is point to
VLSmooth
Tenth Dan Procrastinator
Posts: 3055 Joined: Fri Jul 18, 2003 3:02 am
Location: Varies
Contact:
Post
by VLSmooth » Fri Mar 05, 2004 5:55 pm
Notice
and
I intended to print out all the elements in someVector...
more background:
someVector = class attribute
someOtherVector = input parameter (was a vector)
Granted, this was one error in 52 files I modified...
* VLSmooth smacks himself again
Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790 Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA
Post
by Peijen » Wed Mar 10, 2004 9:27 pm
Code: Select all
SQLBindCol(sql_h_list_stmt, 1, SQL_C_TCHAR, &rate_table_name, 64*tchar_size, &dummy);
SQLBindCol(sql_h_list_stmt, 2, SQL_C_SHORT, &rate_table_code, 0, &dummy);
SQLBindCol(sql_h_list_stmt, 3, SQL_C_SHORT, &age_size, 0, &dummy);
SQLBindCol(sql_h_list_stmt, 4, SQL_C_SHORT, &dur_size, 0, &dummy);
sql_query = L"SELECT rate_table_code, rate_table_name, age, duration FROM lRateTableList;";
...
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Wed Mar 10, 2004 9:51 pm
age_size is not the same as age and dur_size is not the same as duration?
Peijen
Minion to the Exalted Pooh-Bah
Posts: 2790 Joined: Fri Jul 18, 2003 2:28 pm
Location: Irvine, CA
Post
by Peijen » Wed Mar 10, 2004 10:40 pm
(rate_table_name, rate_table_code) ordering between the bind and actual select statment
took me 3 hours ...
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Thu Mar 18, 2004 2:08 am
I don't think anyone will be able to catch this one, because the bug is in the intentions of the programmer, not the code.
Original:
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (one_bit_overlap ? 1 : 0));
I tried to add the possibility of a two_bit_overlap.
Changed to:
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (one_bit_overlap ? 1 : 0) - (two_bit_overlap ? 1 : 0));
quantus
Tenth Dan Procrastinator
Posts: 4891 Joined: Fri Jul 18, 2003 3:09 am
Location: San Jose, CA
Post
by quantus » Thu Mar 18, 2004 3:10 am
Dwindlehop wrote: I don't think anyone will be able to catch this one, because the bug is in the intentions of the programmer, not the code.
Original:
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (one_bit_overlap ? 1 : 0));
I tried to add the possibility of a two_bit_overlap.
Changed to:
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (one_bit_overlap ? 1 : 0) - (two_bit_overlap ? 1 : 0));
Ok, lemme guess, you thought you were using one-hot coding when you implemented the part determining what to set one_bit_overlap and two_bit_overlap to. Meanwhile, you are checking it in such a way that if two_bit_overlap is set, one_bit_overlap is expected to be set as well. So in short, you didn't keep your coding schemes in sink? Is that about right?
VLSmooth
Tenth Dan Procrastinator
Posts: 3055 Joined: Fri Jul 18, 2003 3:02 am
Location: Varies
Contact:
Post
by VLSmooth » Thu Mar 18, 2004 5:42 pm
In short, did you want this?
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (two_bit_overlap ? 2 : (one_bit_overlap ? 1 : 0)));
In other words,
Code: Select all
if (two_bit_overlap) {
return 2;
} else if (one_bit_overlap) {
return 1;
} else {
return 0;
}
Since, as Joe also pointed out, you never guaranteed the status of one_bit_overlap when two_bit_overlap is set.
ps. Intentions of the programmer equates to your semantics correct? (Which aren't given, hence it's impossible to determine if we're correct, on even on track. whee~)
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Thu Mar 18, 2004 6:24 pm
Impressive.
That is largely correct. two_bit_overlap only has meaning if one_bit_overlap is asserted. When one_bit_overlap is false and two_bit_overlap is true, the correct behavior is to have zero overlap.
I had to run a regression to catch that one.
VLSmooth
Tenth Dan Procrastinator
Posts: 3055 Joined: Fri Jul 18, 2003 3:02 am
Location: Varies
Contact:
Post
by VLSmooth » Thu Mar 18, 2004 7:46 pm
Ah, so:
Code: Select all
mask = generate_mask(num_bits)<<(bits_used - (one_bit_overlap ? (two_bit_overlap ? 2 : 1) : 0));
Code: Select all
if (one_bit_overlap) {
if (two_bit_overlap) {
return 2;
} else {
return 1;
}
} else {
return 0;
}
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Thu Mar 18, 2004 8:12 pm
Indeed.
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Sat Apr 17, 2004 12:57 am
I still can't figure out why this makes bar = 7 for all values of x that I tested.
quantus
Tenth Dan Procrastinator
Posts: 4891 Joined: Fri Jul 18, 2003 3:09 am
Location: San Jose, CA
Post
by quantus » Sat Apr 17, 2004 1:14 am
what values of x did you test? 7,15,47, etc?
Jonathan
Grand Pooh-Bah
Posts: 6722 Joined: Tue Sep 19, 2006 8:45 pm
Location: Portland, OR
Contact:
Post
by Jonathan » Sat Apr 17, 2004 1:24 am
outputs of a function.