Giter Site home page Giter Site logo

Comments (10)

Patashu avatar Patashu commented on May 25, 2024

Former I think is worth fixing. When it doesn't introduce huge performance losses, basic stuff should work the way it works in Number.

Latter is working as intended. Only use fc_nn if you know what you're doing or you're willing to accept arbitrary consequences.

from break_eternity.js.

jakub791 avatar jakub791 commented on May 25, 2024

Ok, thanks for answer.
Honestly yeah, about the 2nd one, you should face the consequences of creating arbitary non-normalized Decimals.

from break_eternity.js.

jakub791 avatar jakub791 commented on May 25, 2024

Hmm. Just throught about it now - new Decimal(true) is 0 which is also probably unexpected?

from break_eternity.js.

Patashu avatar Patashu commented on May 25, 2024

I have no idea what that should be. Probably undefined behaviour - why would you ever write that on purpose?

from break_eternity.js.

jakub791 avatar jakub791 commented on May 25, 2024

Because Number(true) is 1 shouldn't new Decimal(true) be 1 too?

from break_eternity.js.

Patashu avatar Patashu commented on May 25, 2024

I guess! (Does break_infinity also fail this?)

from break_eternity.js.

jakub791 avatar jakub791 commented on May 25, 2024

Uh, I don't know. I can check

from break_eternity.js.

James103 avatar James103 commented on May 25, 2024

I just tested in FE000000, which uses break_infinity.min.js and new Decimal(true) throws TypeError: t.indexOf is not a function with stacktrace s.fromString, new s.

Throws exception from here (-1 !== t.indexOf("e")):

        s.prototype.fromString = function(t) {
            if (-1 !== t.indexOf("e")) {
                var n = t.split("e");

from break_eternity.js.

jakub791 avatar jakub791 commented on May 25, 2024

Oh, because it tries to do fromString if input is not undefined, Decimal or number.

from break_eternity.js.

MathCookie17 avatar MathCookie17 commented on May 25, 2024

First statement evaluates to true now, as 1.4.1 normalizes infinities. However, second statement is still false, as I set negative infinity to be normalized to have layer Infinity rather than negative Infinity. Patashu, can you explain why Decimal.dNegInf has layer -Infinity? Shouldn't it have sign -1, mag Infinity, layer Infinity? I guess I should have tested 1.4.1 a little more - I'll have to make a 1.4.2 fixing this, but first I think we need to decide what negative infinity should be and why.

Fourth and fifth statements are now false, as they should be. Third is still false, but that's actually intended - NaN is not equal to itself, that's a rule of floating point. In fact, Decimal.eq(Decimal.NaN, Decimal.NaN) returns false.

EDIT: Okay, I've submitted a pull request that makes the normalization of infinities have {-1, -Infinity, -Infinity} for negative infinity, and this makes your second statement true. Once that pull request is merged, this issue can be closed.

EDIT 2: This issue is solved - well, unless we care about the Decimal(true) thing.

from break_eternity.js.

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.