Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## latest #2918 +/- ##
=======================================
Coverage 81.54% 81.54%
=======================================
Files 347 347
Lines 86865 86942 +77
=======================================
+ Hits 70838 70901 +63
- Misses 16027 16041 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
You've commented before on the use of C-style casts in code I've written, and it's almost always when using int formatting in printf for identifiers that are HighsInt, or size_t. I've just looked up reasons not to use C-style casts, and see that there are four C++ casts that it can mask - depending on the argument? I don't understand these, but what was clear is that int(i) is never ambiguous. For me it's far more readable than static_cast(i), to say nothing of the speed of typing. So, if I'm correct in saying that int(i) is never ambiguous - and my extensive use of it without problem in HiGHS suggests that it is - then it comes down to the programmer's style. Am I correct? |
|
I see that in a couple of places @haman80 is casting size_t to HighsInt, and then using HIGHSINT_FORMAT in printf. Although I was around when it was introduced, I find that it makes formatting very hard to read, which is why I cast to int. I know that, in theory, overflow can occur, but in HiGHS the only practical need for HighsInt is for start pointers in compressed column/row storage of sparse matrices, as the number of nonzeros may exceed 2,147,483,647 (Google wanted it so they could use our presolve). I think it's safe to assume that the number of rows and columns in a problem won't exceed this value - and I'm only talking about printf. |
An excerpt from a discussion on stack overflow:
I think that it is better to be explicit and use But, if this is controversial, I am also fine with keeping the code as it is. |
|
It's not just a matter of style, and my €/£/$0.02 is that we should strongly prefer Just to restate what Franz said, this time using another answer from Stack Overflow Answer to question "C++ cast syntax styles"
|
|
I totally agree with using '*_cast' if there's the least chance of misinterpretation or we need to search for the use cases. However, if I'm right in saying that int(i) is always interpreted correctly when i is HighsInt or size_t - and please correct me if it might not be - then it's a matter of personal style. There's also an argument for only using '*_cast' when necessary so that searches aren't swamped by all the uses when printing HighsInt or size_t 😅 |
|
Hi all, |
iis_strategy = kIisStrategyIrreducible