Interop.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #include "il2cpp-config.h"
  2. #include "Interop.h"
  3. #include <stdio.h>
  4. namespace il2cpp
  5. {
  6. namespace icalls
  7. {
  8. namespace mscorlib
  9. {
  10. // int ves_icall_Interop_Sys_DoubleToString(double value, char *format, char *buffer, int bufferLength)
  11. int32_t Interop::Sys::DoubleToString(double value, char* format, char* buffer, int32_t bufferLength)
  12. {
  13. #if IL2CPP_TARGET_ARMV7
  14. /* workaround for faulty vcmp.f64 implementation on some 32bit ARM CPUs */
  15. int64_t bits = *(int64_t *)&value;
  16. if (bits == 0x1) /* 4.9406564584124654E-324 */
  17. {
  18. IL2CPP_ASSERT(!strcmp(format, "%.40e"));
  19. return snprintf(buffer, bufferLength, "%s", "4.9406564584124654417656879286822137236506e-324");
  20. }
  21. else if (bits == 0x4) /* 2E-323 */
  22. {
  23. IL2CPP_ASSERT(!strcmp(format, "%.40e"));
  24. return snprintf(buffer, bufferLength, "%s", "1.9762625833649861767062751714728854894602e-323");
  25. }
  26. #endif
  27. return ::snprintf(buffer, bufferLength, format, value);
  28. }
  29. } // namespace mscorlib
  30. } // namespace icalls
  31. } // namespace il2cpp