@@ -491,51 +491,44 @@ HCIMPLEND
491491#include < optsmallperfcritical.h>
492492
493493/* ********************************************************************/
494- //
495- HCIMPL1_V (double , JIT_ULng2Dbl, UINT64 val)
494+ HCIMPL1_V (double , JIT_ULng2Dbl, uint64_t val)
496495{
497496 FCALL_CONTRACT;
498-
499- double conv = (double ) ((INT64) val);
500- if (conv < 0 )
501- conv += (4294967296.0 * 4294967296.0 ); // add 2^64
502- _ASSERTE (conv >= 0 );
503- return (conv);
497+ return (double )val;
504498}
505499HCIMPLEND
506500
507501/* ********************************************************************/
508- // needed for ARM and RyuJIT-x86
509- HCIMPL1_V (double , JIT_Lng2Dbl, INT64 val)
502+ HCIMPL1_V (double , JIT_Lng2Dbl, int64_t val)
510503{
511504 FCALL_CONTRACT;
512- return double (val) ;
505+ return ( double )val ;
513506}
514507HCIMPLEND
515508
516509/* ********************************************************************/
517- HCIMPL1_V (INT64 , JIT_Dbl2Lng, double val)
510+ HCIMPL1_V (int64_t , JIT_Dbl2Lng, double val)
518511{
519512 FCALL_CONTRACT;
520513
521- #if defined(TARGET_X86) || defined(TARGET_AMD64)
514+ #if defined(TARGET_X86) || defined(TARGET_AMD64) || defined(TARGET_ARM)
522515 const double int64_min = -2147483648.0 * 4294967296.0 ;
523516 const double int64_max = 2147483648.0 * 4294967296.0 ;
524- return (val != val) ? 0 : (val <= int64_min) ? INT64_MIN : (val >= int64_max) ? INT64_MAX : (INT64 )val;
517+ return (val != val) ? 0 : (val <= int64_min) ? INT64_MIN : (val >= int64_max) ? INT64_MAX : (int64_t )val;
525518#else
526- return ((INT64 )val) ;
527- #endif // TARGET_X86 || TARGET_AMD64
519+ return ( int64_t )val;
520+ #endif
528521}
529522HCIMPLEND
530523
531524/* ********************************************************************/
532- HCIMPL1_V (UINT32 , JIT_Dbl2UIntOvf, double val)
525+ HCIMPL1_V (uint32_t , JIT_Dbl2UIntOvf, double val)
533526{
534527 FCALL_CONTRACT;
535528
536529 // Note that this expression also works properly for val = NaN case
537530 if (val > -1.0 && val < 4294967296.0 )
538- return ((UINT32 )val) ;
531+ return ( uint32_t )val;
539532
540533 FCThrow (kOverflowException );
541534}
@@ -549,14 +542,14 @@ HCIMPL1_V(int, JIT_Dbl2IntOvf, double val)
549542 const double two31 = 2147483648.0 ;
550543 // Note that this expression also works properly for val = NaN case
551544 if (val > -two31 - 1 && val < two31)
552- return ((INT32 )val) ;
545+ return ( int32_t )val;
553546
554547 FCThrow (kOverflowException );
555548}
556549HCIMPLEND
557550
558551/* ********************************************************************/
559- HCIMPL1_V (INT64 , JIT_Dbl2LngOvf, double val)
552+ HCIMPL1_V (int64_t , JIT_Dbl2LngOvf, double val)
560553{
561554 FCALL_CONTRACT;
562555
@@ -565,77 +558,67 @@ HCIMPL1_V(INT64, JIT_Dbl2LngOvf, double val)
565558 // Note that this expression also works properly for val = NaN case
566559 // We need to compare with the very next double to two63. 0x402 is epsilon to get us there.
567560 if (val > -two63 - 0x402 && val < two63)
568- return ((INT64 )val) ;
561+ return ( int64_t )val;
569562
570563 FCThrow (kOverflowException );
571564}
572565HCIMPLEND
573566
574567/* ********************************************************************/
575- HCIMPL1_V (UINT64 , JIT_Dbl2ULngOvf, double val)
568+ HCIMPL1_V (uint64_t , JIT_Dbl2ULngOvf, double val)
576569{
577570 FCALL_CONTRACT;
578571
579572 const double two64 = 4294967296.0 * 4294967296.0 ;
580573 // Note that this expression also works properly for val = NaN case
581574 if (val > -1.0 && val < two64)
582- return (UINT64 )val;
575+ return (uint64_t )val;
583576
584577 FCThrow (kOverflowException );
585578}
586579HCIMPLEND
587580
588- HCIMPL1_V (UINT32 , JIT_Dbl2UInt, double val)
581+ HCIMPL1_V (uint32_t , JIT_Dbl2UInt, double val)
589582{
590583 FCALL_CONTRACT;
591584
592585#if defined(TARGET_X86) || defined(TARGET_AMD64)
593586 const double uint_max = 4294967295.0 ;
594587 // Note that this expression also works properly for val = NaN case
595- return (val >= 0 ) ? ((val >= uint_max) ? UINT32_MAX : (UINT32 )val) : 0 ;
588+ return (val >= 0 ) ? ((val >= uint_max) ? UINT32_MAX : (uint32_t )val) : 0 ;
596589#else
597- return ((UINT32 )val) ;
598- #endif // TARGET_X86 || TARGET_AMD64
590+ return ( uint32_t )val;
591+ #endif
599592}
600593HCIMPLEND
601594
602595/* ********************************************************************/
603- HCIMPL1_V (INT32 , JIT_Dbl2Int, double val)
596+ HCIMPL1_V (int32_t , JIT_Dbl2Int, double val)
604597{
605598 FCALL_CONTRACT;
606599
607600#if defined(TARGET_X86) || defined(TARGET_AMD64)
608601 const double int32_min = -2147483648.0 ;
609602 const double int32_max_plus_1 = 2147483648.0 ;
610- return (val != val) ? 0 : (val <= int32_min) ? INT32_MIN : (val >= int32_max_plus_1) ? INT32_MAX : (INT32 )val;
603+ return (val != val) ? 0 : (val <= int32_min) ? INT32_MIN : (val >= int32_max_plus_1) ? INT32_MAX : (int32_t )val;
611604#else
612- return ((INT32 )val) ;
613- #endif // TARGET_X86 || TARGET_AMD64
605+ return ( int32_t )val;
606+ #endif
614607}
615608HCIMPLEND
616609
617610/* ********************************************************************/
618- HCIMPL1_V (UINT64 , JIT_Dbl2ULng, double val)
611+ HCIMPL1_V (uint64_t , JIT_Dbl2ULng, double val)
619612{
620613 FCALL_CONTRACT;
621614
622615#if defined(TARGET_X86) || defined(TARGET_AMD64)
623616 const double uint64_max_plus_1 = 4294967296.0 * 4294967296.0 ;
624617 // Note that this expression also works properly for val = NaN case
625- return (val >= 0 ) ? ((val >= uint64_max_plus_1) ? UINT64_MAX : (UINT64)val) : 0 ;
626-
618+ return (val >= 0 ) ? ((val >= uint64_max_plus_1) ? UINT64_MAX : (uint64_t )val) : 0 ;
627619#else
628- const double two63 = 2147483648.0 * 4294967296.0 ;
629- UINT64 ret;
630- if (val < two63) {
631- ret = (INT64)(val);
632- }
633- else {
634- // subtract 0x8000000000000000, do the convert then add it back again
635- ret = (INT64)(val - two63) + I64 (0x8000000000000000 );
636- }
637- return ret;
638- #endif // TARGET_X86 || TARGET_AMD64
620+ return (uint64_t )val;
621+ #endif
639622}
640623HCIMPLEND
641624
0 commit comments