Calculate intermediate vectors as doubles to prevent violating general contract of comparator.