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.

Ability to represent floating point numbers

See original GitHub issue

Overview

At the moment we have (using a Python as a platform example but it’s similar in other languages):

  • integer -> int (Python)
  • number -> decimal.Decimal (Python) - guaranteed to have 100% precision

We don’t have a type to represent numbers when it’s ok to lose some precision in favor of calculation speed. Decimals are really slow in Python/JavaScript/etc

Here is a root issue with benchmarking - https://github.com/frictionlessdata/frictionless-py/issues/461

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rufuspollockcommented, Oct 25, 2022

@roll i’d prefer doing the simplest thing possible at present and use format on number and have a small set of recommended supported values e.g. the classic float, double etc but allow given community to add whatever agreed values they want. You could even hack decimal places into this to start with by doing decimalPlaces2, decimalPlaces3 etc.

@roll i’m happy with you to run with a recommendation on this one and trial into the frictionless framework and if you have something working well for us to “standardize” as it were.

0reactions
dafedercommented, Oct 21, 2022

We may be trying to solve too many problems at once here, and there may be a reason so many standards just avoid dealing with this problem, but that doesn’t exactly help people who need to represent something specific like currency that has two decimal places. If we wanted to just address the decimal problem, it could be with a new constraint of scale or something similar. IE maxLength of 12 but scale of 2 means you can have a number with 12 total digits, two of which are to the right of the decimal. This seems consistent with both python’s decimal module and how decimal types are implemented in most SQL systems. To be closer to SQL we could use precision instead of maxLength but maxLength already exists and the two seem redundant.

Another solution I’ve seen suggested is "multipleOf": 0.01. But I can’t say I love that 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Floating-point arithmetic - Wikipedia
A floating-point system can be used to represent, with a fixed number of digits, numbers of very different orders of magnitude — such...
Read more >
Representing Floating Point Numbers
Eight digits are used to represent a floating point number : two for the exponent and six for the mantissa. The sign of...
Read more >
Floating Point Representation - Basics - GeeksforGeeks
Accuracy in floating point representation is governed by number of significant bits, whereas range is limited by exponent. Not all real numbers ......
Read more >
4.8. Floating Point Numbers — CS160 Reader - Chemeketa CS
We are considering a simple example of how floating-point numbers work - real systems have a few extra details like special values to...
Read more >
Floating Point Number - an overview | ScienceDirect Topics
Floating point numbers are used to represent noninteger fractional numbers and are used in most engineering and technical calculations, for example, 3.256, ...
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