I'm aware of floating point inaccuracies, but I need a way around them.
So, I need to do a graph traversal, and I'm doing it by getting all the nodes into the stack, adding routes to all the neighbors, then adding a large route to all the non-neighbors, finally going through and finding the best routes. It works fine for the routes that were created from the neighbors, but it breaks on the routes that were created with a large number.
Here's the relevant sections of code.
Here the large route is assigned.
movsd xmm0, [big]
mov [r11+rax+TAR], r9
movsd [r11+rax+DIS], xmm0
mov [r11+rax+HOP], r9
Here the comparison is made, in order to see if a better route is found.
ucomisd xmm0, xmm2
ja bMBD
jmp eMBD
bMBD:
mov rax, [r8+ROT]
mov [rax+r13+HOP], r11
movsd [rax+r13+DIS], xmm2
eMBD:
The above block of code is where the problem is, following is a breakdown of what I believe the code is doing.
D asks D for better route, but nothing happens: good.
D asks A, finds one and calculates distance as 3.3+5.4=8.7, it's better and replaces it's current route: good.
D asks B, finds one with a distance of 8.7+0=8.7. For some reason this is regarded as better and it's route is replaced: bad.
So, why is the ja
condition returning that 8.7 > 8.7, but only on the routes that had their distance initialized to a large number (I've tried reducing the size of the number, but that has yielded the same results)?
Thank You.