GithubHelp home page GithubHelp logo

Comments (5)

kzangeli avatar kzangeli commented on August 29, 2024

Yeah, this is no good ...
Floats are like that, unfortunately. That's kind of how a computer works. It's not apt to treat floats, only integers. There are rounding errors.
The only way to really fix this problem is to store floats as strings and during serialization, render them also as strings but without quotes. This fixes that particular problem to 100%. But, another one is introduced. The 'q' and 'mq' filters would stop working, as the float is no longer a float but a string.
To fix also this problem, we'd need to store not one value but two, a string for rendering and a float for comparison ...

In short, this is a pretty complex problem and will need some thought before we decide how to fix it.

from context.orion-ld.

jmcanterafonseca avatar jmcanterafonseca commented on August 29, 2024

why the latitude does not suffer from that problem?

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

Well, these are rounding errors.
It all depends on how the value is stored inside its float.
Sometimes a value e.g. 13 gets stored as 13.00000000001.
Computers aren't made for floating numbers ...
Always preferable to use integers, like storing milliseconds instead of seconds etc.
That said, there is a possible fix, as I mentioned before - to store TWO values instead of one.

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

I will make a simple test and see how the value 75.01 is stored in mongo.
But, as I mentioned, there will always be rounding errors, not much we can do about it -
except for storing two different values, a string for rendering and a float for comparisons.

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

Said and done.
PR #59 tests the rounding problem both for what is stored in mongo and the response with GET.
In my Ubuntu laptop there is no rounding error.
However, this is no guarantee for that it will work also in other machines ...

from context.orion-ld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.