6 ms·
That works just great if your numbers are positive, but if they are both positive and negative, and in almost but not quite equal pairings it will fail to give
by aardvark179 2y ago
That works just great if your numbers are positive, but if they are both positive and negative, and in almost but not quite equal pairings it will fail to give the best answer even if you prioritise by magnitude.
- deleted 2y ago[deleted]
- recursive 2y agoIf it works for positives, then you can add all the positives in one bin, add all the negatives in one bin, and finish off with a single subtraction.
- anonymoushn 2y agoThat isn't a great method, see here: https://en.wikipedia.org/wiki/Catastrophic_cancellation https://en.wikipedia.org/wiki/Catastrophic_cancellation I wonder what methods give good results for this sort of input though.