Example
Sally alerted her accountant to four to five digit revenue discrepancies in the budget.
Should it be:
...to four to five digit revenue discrepancies
or with a suspended hyphen:
...to four- to five-digit revenue discrepancies
Example
Sally alerted her accountant to four to five digit revenue discrepancies in the budget.
Should it be:
...to four to five digit revenue discrepancies
or with a suspended hyphen:
...to four- to five-digit revenue discrepancies
In your new use case, the phrase is being used as an adjective, so you do need the hyphens.
Sally alerted her accountant to four- to five-digit revenue discrepancies in the budget.
There seem to be a couple questions here, and I'll address them all, plus another error.
There is no reason at all to use hyphens here. It's Four digits, and four digits ahead, making it a range doesn't add hyphens.
I was taught to spell out integers less than 10, and ten or more when used together, so four to five digits, or nine to ten digits, 20 to 30 digits. Of course, for informal writing, just the numbers will be fine, and you can usually get away with using a hyphen instead of to: 4-5 digits.
Finally, I don't think digits is the word you want here. A digit is just a character, a single glyph. If the other students average 50, four digits ahead would mean that Sally regularly finishes with a score of 500,000. You are looking for points or percentage points, depending on how the work is scored.
So the whole sentence you're looking for is
Out of 100, Sally regularly finishes four to five points ahead of her classmates.