You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my experience it's best to split code over several lines and use {curly braces} even in cases where they're technically not necessary. It's longer but really boosts the readability.
if (j0s != 0) j0s = jj0* log2(jj0); if (j1s != 0) j1s = jj1* log2(jj1); if (j2s != 0) j2s = jj2* log2(jj2); if (j3s != 0) j3s = jj3* log2(jj3); //Gives 0 in entropy!
It would be way better written as this:
if (j0s != 0) {
j0s = jj0* log2(jj0);
}
if (j1s != 0) {
j1s = jj1* log2(jj1);
}
if (j2s != 0) {
j2s = jj2* log2(jj2);
}
if (j3s != 0) {
j3s = jj3* log2(jj3);
}
//Gives 0 in entropy!
Yes, it takes more lines of code, but there isn't a global newline shortage.
Some libraries can do more mnemonic approaches, by providing higher level concepts like vectors and quaternions and so on. I don't know if any of those would be applicable to your code; adopting one of those would certainly be a lot of work.
The text was updated successfully, but these errors were encountered:
In my experience it's best to split code over several lines and use
{
curly braces}
even in cases where they're technically not necessary. It's longer but really boosts the readability.For example, consider this line:
PCC_Processing_Design/src/lib/PCC_Characterisation/functions/analytical_solutions.h
Line 25 in 23c8e07
It would be way better written as this:
Yes, it takes more lines of code, but there isn't a global newline shortage.
Some libraries can do more mnemonic approaches, by providing higher level concepts like vectors and quaternions and so on. I don't know if any of those would be applicable to your code; adopting one of those would certainly be a lot of work.
The text was updated successfully, but these errors were encountered: