Двоичный формат не должен изменяться - это, конечно, будет повреждающееся изменение в существующих спецификациях. Это определяется, чтобы быть в IEEE754 / IEC 60559:1989 формат, как сказал Jimmy. (Раздел спецификации C# 3.0 языка 1.3; раздел ECMA 335 8.2.2). Код в DoubleConverter должен быть прекрасным и быть устойчивым.
Ради будущей ссылки, соответствующий бит кода в примере:
public static string ToExactString (double d)
{
…
// Translate the double into sign, exponent and mantissa.
long bits = BitConverter.DoubleToInt64Bits(d);
// Note that the shift is sign-extended, hence the test against -1 not 1
bool negative = (bits & (1L << 63)) != 0;
int exponent = (int) ((bits >> 52) & 0x7ffL);
long mantissa = bits & 0xfffffffffffffL;
// Subnormal numbers; exponent is effectively one higher,
// but there's no extra normalisation bit in the mantissa
if (exponent==0)
{
exponent++;
}
// Normal numbers; leave exponent as it is but add extra
// bit to the front of the mantissa
else
{
mantissa = mantissa | (1L << 52);
}
// Bias the exponent. It's actually biased by 1023, but we're
// treating the mantissa as m.0 rather than 0.m, so we need
// to subtract another 52 from it.
exponent -= 1075;
if (mantissa == 0)
{
return negative ? "-0" : "0";
}
/* Normalize */
while((mantissa & 1) == 0)
{ /* i.e., Mantissa is even */
mantissa >>= 1;
exponent++;
}
…
}
комментарии имели смысл мне в то время, но я уверен, что должен был бы думать некоторое время о них теперь. После самой первой части у Вас есть "необработанная" экспонента и мантисса - остальная часть кода просто помогает рассматривать их более простым способом.
Я создал расширение emacs для интеграции rvm в emacs. Если вам интересно, вы можете получить его здесь: http://github.com/senny/rvm.el
Попробуйте настроить exec-path
: Mx customize-option RET exec-path RET