question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Summing a list of floating-point numbers

See original GitHub issue

What is the purpose of sorting these floats? After sorting, they are summed and their total is returned. The ResizeArray was created in this scope and no references remain after the function returns. Maybe it was added at one point to help with debugging.

I think this sorting can be removed.

https://github.com/fslaborg/flips/blob/16a347c18cbfd7eb4c12d6c57dea31b56dd7b54d/Flips/Types.fs#L254-L258

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
TysonMNcommented, Dec 31, 2020

That is very clever. Thanks for the explanation and specific example.

I will make sure there is a test that fails if the sort is removed before closing this issue.

1reaction
TysonMNcommented, Feb 9, 2021

That’s fine. PR #170 is just a proof of concept.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sum of float numbers in a list in Python
To sum float from a list , one easy way is to use fsum import math l=[0.0, 0.0, 1.0, 0.0, 0.25, 0.25] math.fsum(l)....
Read more >
Python sum()
Output: 7.0 If you want to add floating point values with extended precision, you can use math.fsum() function. Python sum of complex numbers....
Read more >
How to Sum a List of Float numbers in Python
Use the map.fsum() method to sum a list of float numbers in Python. The math.fsum() method returns an accurate sum of the floating-point...
Read more >
Summing an array of floating point numbers | Kahan
This post will look at Kahan's algorithm, one of the first non-obvious algorithms for summing a list of floating point numbers.
Read more >
Python sum() Function
Example two of sum() has a list of floating-point values. We again pass that list of floating-point numbers to the sum() function, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found