Sloppy method /math help

if you picture swiping the mouse from the center of an octagon outward, i want to calculate which one of the 8 sides you are within.
If i have the angle in degrees, i currently state:


if (degrees > -22.5 && degrees <= 22.5)
{
    txt.text = "1";
}
else if (degrees > -22.5 && degrees <= 67.5)
{
    txt.text = "2";
}
else if (degrees > 67.5 && degrees <= 112.5)
{
    txt.text = "3";
}
else if (degrees > 112.5 && degrees <= 157.5)
{
    txt.text = "4";
}
else if ((degrees > 157.5 && degrees <= 180)|| (degrees >= -180 && degrees <=-157.5))
{
    txt.text = "5";
}
else if (degrees > -157.5 && degrees <=-112.5)
{
    txt.text = "6";
}
else if ( degrees >-112.5 && degrees<=-67.5)
{
    txt.text = "7";
}
else if (degrees>-67.5&& degrees<=-22.5)
{
    txt.text = "8";
}

This of course does work, but it seems a little extensive to check up to 8 statements to find this answer. What would be a better way to approach this?

thanks