Wow ... I've never seen this before. Any way around this?
foreach( double r in portfolioReturns) { if (-8.0 < r < -7.0) { n8++; }}
You do it effectively
if ((-8.0 < r) < -7.0)
Since (-8.0 <r) evaluates to logical, you cannot compare it to a float. Do this instead:
if (-8.0 < r && r < -7.0) { //code here }
if (-8.0 < r && r < -7.0)
, python? , , : -)
(-8.0 < r < -7.0), -, -8.0 < r , . true < -7.0 barfs.
(-8.0 < r < -7.0)
You can also use LINQ, in addition to the fix that is all so quickly provided
n8 += portfolioReturns.Count(r => -8.0 < r && r < -7.0);
foreach(double r in portfolioReturns) { if(-8.0 < r && r < -7.0) n8++; }
Source: https://habr.com/ru/post/1761435/More articles:Android thinks I'm not closing my database! What for? - javaHighlighting days on a calendar - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1761432/google-app-engine-reference-property-that-references-to-4-models-or-more&usg=ALkJrhhi9X4BBjRNSPZagkUKdYS_oCNHMgAssigning a function leads to a variable inside a PHP class? Tumor - functionhow to log in to WebSVN - svncopying a sub-vector - c ++Why is my code not compiling? - f #How can I execute a JS function from the top of the stack? - javascriptHow can I do the modeling in the reverse order by parsing the C program and including it in the circuit that will be displayed - cCan a function know if it works inside a coroutine? - luaAll Articles