Advertisement
Sc2ad

decimal/single/double il2cpp

Feb 12th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.31 KB | None | 0 0
  1. #if !NET_4_0
  2. // System.Decimal
  3. typedef struct
  4. {
  5.     //Note that we are not taking care of endianess.
  6.     union
  7.     {
  8.         uint32_t ss32;
  9.         struct signscale
  10.         {
  11.             unsigned int reserved1 : 16;
  12.             unsigned int scale : 8;
  13.             unsigned int reserved2 : 7;
  14.             unsigned int sign : 1;
  15.         } signscale;
  16.     } u;
  17.     uint32_t hi32;
  18.     uint32_t lo32;
  19.     uint32_t mid32;
  20. } il2cpp_decimal_repr;
  21. #else
  22.  
  23. typedef struct Il2CppDecimal
  24. {
  25.     // Decimal.cs treats the first two shorts as one long
  26.     // And they seriable the data so we need to little endian
  27.     // seriliazation
  28.     // The wReserved overlaps with Variant's vt member
  29. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  30.     union
  31.     {
  32.         struct
  33.         {
  34.             uint8_t sign;
  35.             uint8_t scale;
  36.         } u;
  37.         uint16_t signscale;
  38.     } u;
  39.     uint16_t reserved;
  40. #else
  41.     uint16_t reserved;
  42.     union
  43.     {
  44.         struct
  45.         {
  46.             uint8_t scale;
  47.             uint8_t sign;
  48.         } u;
  49.         uint16_t signscale;
  50.     } u;
  51. #endif
  52.     uint32_t Hi32;
  53.     union
  54.     {
  55.         struct
  56.         {
  57.             uint32_t Lo32;
  58.             uint32_t Mid32;
  59.         } v;
  60.         uint64_t Lo64;
  61.     } v;
  62. } Il2CppDecimal;
  63.  
  64. // Structure to access an encoded double floating point
  65. typedef struct Il2CppDouble
  66. {
  67. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  68.     uint32_t sign : 1;
  69.     uint32_t exp : 11;
  70.     uint32_t mantHi : 20;
  71.     uint32_t mantLo : 32;
  72. #else // BIGENDIAN
  73.     uint32_t mantLo : 32;
  74.     uint32_t mantHi : 20;
  75.     uint32_t exp : 11;
  76.     uint32_t sign : 1;
  77. #endif
  78. } Il2CppDouble;
  79.  
  80. typedef union Il2CppDouble_double
  81. {
  82.     Il2CppDouble s;
  83.     double d;
  84. } Il2CppDouble_double;
  85.  
  86. typedef enum Il2CppDecimalCompareResult
  87. {
  88.     IL2CPP_DECIMAL_CMP_LT = -1,
  89.     IL2CPP_DECIMAL_CMP_EQ,
  90.     IL2CPP_DECIMAL_CMP_GT
  91. } Il2CppDecimalCompareResult;
  92.  
  93. // Structure to access an encoded single floating point
  94. typedef struct Il2CppSingle
  95. {
  96. #if IL2CPP_BYTE_ORDER == IL2CPP_BIG_ENDIAN
  97.     uint32_t sign : 1;
  98.     uint32_t exp : 8;
  99.     uint32_t mant : 23;
  100. #else
  101.     uint32_t mant : 23;
  102.     uint32_t exp : 8;
  103.     uint32_t sign : 1;
  104. #endif
  105. } Il2CppSingle;
  106.  
  107. typedef union Il2CppSingle_float
  108. {
  109.     Il2CppSingle s;
  110.     float f;
  111. } Il2CppSingle_float;
  112.  
  113. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement