36 int *address_as_int =
reinterpret_cast<int *
>(address);
37 int old = *address_as_int, assumed;
41 old = atomicCAS(address_as_int,
43 atomicMax(address_as_int, __float_as_int(val)));
45 while (assumed != old);
47 return __longlong_as_double(old);
60 unsigned long long int *address_as_ull =
61 reinterpret_cast<unsigned long long int *
>(address);
62 unsigned long long int old = *address_as_ull, assumed;
66 old = atomicCAS(address_as_ull,
68 atomicMax(address_as_ull,
69 static_cast<unsigned long long int>(
70 __double_as_longlong(val))));
72 while (assumed != old);
74 return __longlong_as_double(old);