I am quite confident that this is not possible with standard formating. I suggest to use something like the following (C# like pseudo code). Especially I suggest to rely on string operations and not to use math code because of many possible precision and rounding problems.
string numberString = number.ToStringWithFullPrecision();
int index = numberString.IndexOf('.');
while ((index < numberString.Length - 1) && (numberString[index + 1] == '9'))
{
index++;
}
WriteLine(number.PadRightWithThreeZeros().SubString(0, index + 4));
If you like regular expression, you can use them to. Take the following expression and match it against the full precision number string padded with three zeros and you are done.
^([0-9]|[1-9][0-9]|100)\.(9*)([0-8][0-9]{2})
I just realized that both suggestion may cause rounding errors. 99.91238123
becomes 99.9123
when it should become 99.9124
- so the last digits requires additional correction. Easy to do, but makes my suggestion even uglier. This is far away from an elegant and smart algorithm.