0

Why can't we use float value in switch statement

switch(4.2) // Why is this not valid?

31st Mar 2021, 4:11 AM
Illa Bahadur Darlami Magar
Illa Bahadur Darlami Magar - avatar
1 Resposta
0
First you don't use 'switch()' that way because you're supposed to put a variable not a raw input. And second floats are imprecise so you cannot use them in 'switch()' but as i know there is a few tricks to by pass that.
31st Mar 2021, 4:31 AM
Carbon
Carbon - avatar