0

This question is opposite to my another this question. I need to do opposite operation. I have c# decimal which I need to convert to this structure:

    public struct significand
    {
        public uint mantissa;  // or ulong
        public sbyte exponent;
    }

I pass this structure to c++ library via p/invoke later. How can I convert decimal to this structure? I guess probably I should use Decimal.GetBits method somehow? Or probably I can declare c++ structure some way so decimal will be automatically converted to it (i think they should be binary-compatible). Currently i'm using such c++ struct:

struct significand_t
{
uint32_t mantissa;
int8_t exponent;
};
4

1 回答 1

-1

看看这里关于二进制浮点和.NET

您会发现一些示例代码的链接对您的案例很有用。

--r

于 2013-10-08T14:03:20.917 回答