Setting extra bits in a bool makes it true and false at the same time

In C++ the bit representation (and even the size) of a bool is implementation defined; generally it’s implemented as a char-sized type taking 1 or 0 as possible values. If you set its value to anything different from the allowed ones (in this specific case by aliasing a bool through a char and modifying its … Read more

SQL UPDATE order of evaluation

MySQL does “left to right” evaluation and does “see” the new values. (Tested on 5.0.45-community-nt-log MySQL Community Edition) Furthermore, from the MySQL manual: “Single-table UPDATE assignments are generally evaluated from left to right. For multiple-table updates, there is no guarantee that assignments are carried out in any particular order.” Now, “generally” is quite vague and … Read more

Difference between i++ and (i)++ in C

i++ and (i)++ behave identically. C 2018 6.5.1 5 says: A parenthesized expression is a primary expression. Its type and value are identical to those of the unparenthesized expression. It is an lvalue, a function designator, or a void expression if the unparenthesized expression is, respectively, an lvalue, a function designator, or a void expression. … Read more

Is ++x %= 10 well-defined in C++?

As per C++11 1.9 Program execution /15: Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced. If a side effect on a scalar object is unsequenced relative to either another side effect on the same scalar object or a value computation using the value of the same … Read more

In Java, what are the boolean “order of operations”?

The Java Tutorials has a list illustrating operator precedence. The equality operators will be evaluated first, then &&, then ||. Parentheses will be evaluated before anything else, so adding them can change the order. This is usually pretty much the same from language to language, but it’s always a good idea to double check. It’s … Read more

Evaluation & Calculate Top-N Accuracy: Top 1 and Top 5

Top-1 accuracy is the conventional accuracy: the model answer (the one with highest probability) must be exactly the expected answer. Top-5 accuracy means that any of your model 5 highest probability answers must match the expected answer. For instance, let’s say you’re applying machine learning to object recognition using a neural network. A picture of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)