ThomsonReuters.RFA.Data.Real conversion to decimal

The guide of Thomosn. Reuters included that Real has hint to convert the long value to decimal value , can you help me how to do that especially i could not conclude the way from manual

Tagged:

Best Answer

  • Gurpreet
    Gurpreet admin
    Answer ✓

    The RFA.Data.Real has two properties -

    Value - Data. Type: long
    MagnitudeType- enumerated hint for how the value is to be interpreted. Type: RFA.Data.MagnitudeTypeEnum

    Lets assume, you receive a message like this:

    >>dataBuffer.Real
    {Value : 44370000
    MagnitudeType : 8
    }

    Here the magnitude value of 8 expands to ExponentNeg6 (= 10^-6). So the resulting value should be interpreted as 44.370000.

    If you know that RFA.Data.DataBuffer is of type Real, you can also use a handy property .Double to directly get the floating point number.

Answers

  • Hello @omar.isaid1

    Real consist of (byte) MagnitudeType and (long) Value members;
    The Value specifies the mantissa - the value as a whole number, the MagnitudeType indicates the fraction or exponent which applies to this Value member that would yield a decimal value.
    MagnitudeType values are defined in MagnitudeTypeEnum, for example, MagnitudeTypeEnum.ExponentNeg2 indicates power of -2
    So as an example the decimal value 32.35 can be represented using Real like this:

    real.MagnitudeType = MagnitudeTypeEnum.ExponentNeg2;

    real.Value = 3235;

    The decimal value could be obtained like this:

    decimal dec = (Decimal)real.Value / 100;

  • Thank you very much dear , of course I know the nice RFA.NET .Double , but for some reason related to type of project I work in I have to use data in decimal data type not in float or double data type.Althugh , using double and float is great and easy way

    I checked the Enum MsgTypeEnum , now if I have values like : Divisor4
    ExponentPos7
    NegInfinity what is the best decision to do

    I think for ExponentPos7 I have to move the comma of precision to right , but what about the other types like : Divisor , Infinity,NegInfinity , Exponent0 , ExponentPos?

  • The valid MagnitudeType values are defined in class MagnitudeTypeEnum.

    Therefore the byte value 8 expands to the MagnitudeTypeEnum member that is assigned that value, that is: MagnitudeTypeEnum.ExponentNeg6.

  • I tried this method I wonder if it is true ?! if I had MagnitudeType divisor8 then : value number / 8 and so on . if I had Exponent0 then the value is power to 0 which means result =0 ?

  • Where did you get MsgTypeEnum from? The RFA.Data.Real has magnitude as defined in RFA.Data.MagnitudeTypeEnum.

    Exponent0 = 10^0 = 1. So result = value * 1.

    Divisor8 = 1/8. Result = value / 8.

    ExponentPos5 = 10^5. Result = value * 100000

    NegInfinity. Result = -∞

    All other values are self explanatory.

  • Exponent0 means: 10^0

    10^0 == 1 (any base to power 0 == 1)

    So this means that when MagnitudeType == Exponent0 (byte value 14) the number expressed as a Decimal does not have a fractional component, e.g.

    Given a Real value as follows:

    real.Value = 1234; real.MagnitudeType = 14;

    The equivalent decimal value will be:= 1234

  • Thank you very much so clear and great answer , I need to convert to Decimal for the type of my application because double may be cause round internally