Rounding values to nearest 500

Rounding values to nearest 500

I have a series of numbers that run from in the tens to the ten thousands. I want to set the following rounding rules:

Above 10,000, round to nearest 1,000
Below 10,000 but above 1,000, round to nearest 500
Below 1,000, round to nearest 100

// Work out some custom rounding for specific values
    if ( varRec.annual_kWh_saving <= 1000 )
    {
        varKwh = varRec.annual_kWh_saving.toDecimal().round(-2);
    }
else
    {
        varKwh = varRec.annual_kWh_saving.toDecimal().round(-3);
    }

How would I apply rounding to nearest 500?