Yes it can. So you do nothing wrong. if that's indeed what you want.

val = map(math, num, 27000, 0, 10000);

So:

Some math = num it gives you 0

if math = 27000 it gives you 10000

But keep in mind, if math goes below num or over 27000 is also goes under 0 or over 10000. If you are not sure math never goes below num / over 27000 and you want to limit the output to 0 to 10000 you have to limit the input (or the output) as well.

val = map(math, num, 27000, 0, 10000);

if(val < 0){

val = 0;

}

else if(val > 27000){

val = 27000;

}

Or a nice wrapper function

//only map it if it's in range. Otherwise clamp it.

long mapClamped(long x, long in_min, long in_max, long out_min, long out_max){

if(x < in_min){

return out_min;

}

else if(x > in_max){

return out_max;

}

return map(x, in_min, in_max, out_min, out_max);

}