You could use recursion. This would help you work with very small or very large numbers, although I’m sure a programmer could find a more efficient way.
(
~h = {|x| case
{x < 80} {~h.(x*2)}
{x > 160} {~h.(x/2)}
{x}
}
)
// tests
~h.(39);
~h.(79);
~h.(101);
~h.(165);
~h.(340);
~h.(85 * 2.pow(10));
~h.(86.7 * 2.pow(-10));