invalid operands of types 'bool' and 'float' to binary 'operator&'

Hi Foks,

Since many of my students are arduino fans, I bought an Uno, installed the IDE 1.8.5 and started banging.

Ran accross a Project that caught my fancy and though might be interessting to give it a whirl. To wit:


Hacked in the source that supposedly ought to compile at the very least “out of the copy + paste”. ( OK I ought to have given it a once over, but…)!

Well, the Compiler complained that there are glaring type Errors in this Code;
invalid operands of types ‘bool’ and ‘float’ to binary ‘operator&’

Here is the Code:

//Determine the correct frequency and light up
//the appropriate LED for the string being played

Note that frequency is declared as float
void stringCheck(){

correctFrequency = 82.4;

A cast to int placated the complier, to wit:

if(frequency>70& (int ) frequency;<90){
correctFrequency = 82.4;


Not sure that this produces the expected resutls -:slight_smile:

Question to the experts;

Was there ever a Compiler that accepted this semantic? I assume that if the Code is in PD, it must have been executable at some time in the past?

Another quirk of the Compiler is that it flags first the Errors at the end of the file and works upwards to the top. Any reason for this?

Appreciate any comments or thoughts



Please remember to use code tags when posting code

Indeed, ; was a copy from the original, the Code that compiles

if(((frequency>100& (int )frequency))<120){
correctFrequency = 110;

Always be very distrustful of Arduino projects on instructables. They are consistently of terrible quality.

Do you mean:

if((frequency > 100) &[b]&[/b] (frequency < 120) ){