I'm not familiar with XNA but in a Silverlight project where I had to do the same thing I ended up constructing scientific notation numbers from superscript characters.
You don't need a special font, just a Unicode font which has the superscript characters used below.
Heres the code to map digits 0-9 to the appropriate character:
private static string GetSuperscript(int digit)
{
switch (digit)
{
case 0:
return "\x2070";
case 1:
return "\x00B9";
case 2:
return "\x00B2";
case 3:
return "\x00B3";
case 4:
return "\x2074";
case 5:
return "\x2075";
case 6:
return "\x2076";
case 7:
return "\x2077";
case 8:
return "\x2078";
case 9:
return "\x2079";
default:
return string.Empty;
}
}
And this converts your original double into scientific notation
public static string FormatAsPowerOfTen(double? value, int decimals)
{
if(!value.HasValue)
{
return string.Empty;
}
var exp = (int)Math.Log10(value.Value);
var fmt = string.Format("{{0:F{0}}}x10{{1}}", decimals);
return string.Format(fmt, value / Math.Pow(10, exp), FormatExponentWithSuperscript(exp));
}
private static string FormatExponentWithSuperscript(int exp)
{
var sb = new StringBuilder();
bool isNegative = false;
if(exp < 0)
{
isNegative = true;
exp = -exp;
}
while (exp != 0)
{
sb.Insert(0, GetSuperscript(exp%10));
exp = exp/10;
}
if(isNegative)
{
sb.Insert(0, "-");
}
return sb.ToString();
}
So now you should be able to use FormatAsPowerOfTen(123400, 2)
resulting in 1.23x10⁵
.