Top "Correctness" questions

In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification.

Switch statement with returns -- code correctness

Let's say I have code in C with approximately this structure: switch (something) { case 0: return "blah"; break; case 1: case 4: return "…

c switch-statement correctness
Correctness of Sakamoto's algorithm to find the day of week

I am using Sakamoto's algorithm to find out the day of week from a given date. Can anybody tell me …

c algorithm dayofweek correctness
Try / Try-with-resources and Connection, Statement and ResultSet closing

I have recently having some discussions with my professor about how to handle the basic jdbc connection scheme. Suppose we …

java correctness try-with-resources
How to fix the Findbugs issue "Null value is guaranteed to be dereferenced" NP_GUARANTEED_DEREF

Hi I have got some code that is reported as having the NP_GUARANTEED_DEREF issue by Findbugs. Now looking …

java nullpointerexception findbugs dereference correctness
When is the use of std::ref necessary?

Consider: std::tuple<int , const A&> func (const A& a) { return std::make_tuple( 0 , std::ref(…

c++ c++11 portability correctness
How do I use System.Net.ConnectStream?

I am trying to get my head around some of my predecessors code who, helpfully, has used 'var' to declare …

c# correctness
Counting trailing zeros of numbers resulted from factorial

I'm trying to count trailing zeros of numbers that are resulted from factorials (meaning that the numbers get quite large). …

java correctness
When do I need to specify the JavaScript protocol?

I was under the impression that I only need to specify the "protocol" when using JavaScript in URL attributes, such …

javascript correctness