Takes a pointer to an array of 80-bit x87 long doubles and returns in the 2nd element of the array. Loop subnormal_loop #decrements ecx and jmp if not zero Subnormal_loop: #multiply significand by two and subtract exponent by 1 until either exponent is zero or the number is normal multiply significand by two and subtract one off the exponent until the MSB is 1 # so if it's missing, shift the bits around to restore it # the significand of a floating point number always has 1 as its MSB. Shr rsi,cl #shift the smaller significand so they line up # exp1 = 2**64, just return initial number # check which argument is greater and swap the two if the second is greater. # So, just 4 pops puts all the arguments into registers: # rsp+18 -> exponent of second argument (plus six bytes of junk) # rsp+10 -> significand of second argument # rsp+8 -> exponent of first argument (plus six bytes of junk) # Conveniently, long doubles have an alignment of sixteen, so the "stack" now looks like: # with the low 8 bytes giving the significand and the high 2 bytes giving the exponent
![rsi shift exchange rsi shift exchange](https://a.c-dn.net/b/307gAY/USDJPY-Rate-Outlook-Mired-by-Shift-in-Retail-FX-Sentiment_body_USDJPYDailyChart03192019.png)
# long doubles are 80-bit floating point numbers, Xchg esp,edi # save stack pointer and points new stack at the input
#Rsi shift exchange code#
This is a code golf question may the shortest answer win. Standard loopholes are of course not allowed, and the inputs may be given in any format corresponding closely to a float (decimal, 64-bit integer bit representation, etc.). Subnormal numbers ( 1), nonpositive numbers, and non-finite numbers do not need to be supported, but it should output zero when the operands are equal. The answer must have a relative accuracy of 1e-6, i.e., the error should be at most 1e-6 times the correct answer. Given two positive (IEEE-754) double-precision floating-point numbers, find their XOR as numbers. Note that the result is not always exactly representable as a double, but we can round. The values were written out exactly and a bitwise XOR performed.
![rsi shift exchange rsi shift exchange](https://miro.medium.com/max/552/1*RqMLLQQi9Adp3CSgPxC2wQ.jpeg)
![rsi shift exchange rsi shift exchange](https://miro.medium.com/max/552/1*Snknmy0HbYYUqLB5F1mP9g.jpeg)
The bitwise exclusive or (XOR) operation is usually considered in terms of integers, but it can be naturally generalized (extended, in fact!) to real numbers. GitHub STOP HELPING ICE on that challenge, but I thought of this idea independently. This is different from Floating Point XOR, and more in the spirit of a comment by R.