+ 1
Whether float can be use in switch condition?
8 Respostas
+ 4
No.
+ 3
You can pretend by rounding to tenths such as:
switch ((int)round(value*10.0)) {
case 0: //0.0
case 10: //1.0
}
+ 2
I have no idea. Maybe because of the typical unpreciseness of float?
Maybe someone else knows.
+ 1
Why we can't use float in switch
+ 1
Ok 😊
+ 1
Round off first