Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
static void Frexp(double value, out double mantissa, out int exponent)
{
var bits = BitConverter.DoubleToInt64Bits(value);
var negative = (bits & (1L << 63)) != 0;
exponent = (int)((bits >> 52) & 0x7FFL);
Console.WriteLine("nt2: " + exponent);
var mantissaLong = bits & 0xFFFFFFFFFFFFFL;
if (exponent == 0)
{
exponent++;
}
else
{
mantissaLong |= 1L << 52;
}
exponent -= 1075;
if (mantissaLong == 0)
{
mantissa =
a = 3.14
print *,fraction(a), exponent(a)
function frexp(a) {
exponent = ( Math.floor(Math.log(a, 2)) + 1 )
mantissa = ( a * Math.pow(2, -a) )
return [ mantissa, exponent ]
}
local function frexp(a)
return math.frexp(a)
end
puts Math::frexp(a)
let sign = if a < 0.0 { a = -a; -1 } else { 1 };
let exponent = (a + f64::EPSILON).log2().ceil() as i32;
let fraction = a / 2.0f64.powi(exponent);