Giter Club home page Giter Club logo

Comments (3)

kgryte avatar kgryte commented on May 22, 2024 1

@bguiz Agreed. These libraries would be nice to have, but we first want to cover all our bases and get the basics right before moving on to higher order concerns. Much to do, so little time!

Also, if you have any other general questions, feel free to also seek us out and leave a message on Gitter.

from stdlib.

kgryte avatar kgryte commented on May 22, 2024

@bguiz Yeah, thanks for the question. This behavior is expected.

> 0.1 + 0.2
0.30000000000000004

This is not because JavaScript implementors have failed to properly implement floating-point math. The reason the answer is not exactly 0.3 is because not all numbers are exactly representable as double-precision floating-point numbers (see here). In short, addition is working as expected.

In general, this type of imprecision is not an issue, as floating-point rounding errors tend to cancel out. What we are concerned about is the types of algorithms used to implement basic math functions, such as trig and other special functions. The errors arising from these algorithms are of a different kind than the errors arising from floating-point math.

To "address" floating-point errors, you can use symbolic or arbitrary precision arithmetic libraries, which is not currently within the scope of this library, but may at some point in the future.

from stdlib.

bguiz avatar bguiz commented on May 22, 2024

Thanks for the answer!

To "address" floating-point errors, you can use symbolic or arbitrary precision arithmetic libraries, which is not currently within the scope of this library, but may at some point in the future.

With the name stdlib I think including this at some point in the future might make sense. For example, you already have some util functions which overlap with these libraries, for example this one which converts a higher precision float to a lower precision one: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/utils/float64-to-float32

from stdlib.

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.