Limit length of number irrespect of decimal places

I need to return a max of 8 digits to any number (not inc decimal point if necessary), but also want a max of 4 decimal places if the calculation provides a results with more than 4 dec places. This is because i have a max space of 8 characters + dec place.

eg

10.0908 (fewer than 8 digits so full 4 decimal places)

1908978.5 (max digits so could only return 1 dec place)

222.0192 (fewer than 8 digits so full 4 dec places shown)

1.19 (this is full answer so no changes required as !=> 8 digits & dec places<4 any way)

Hope this makes sense!!