Git Product home page Git Product logo

Comments (12)

infradig avatar infradig commented on July 28, 2024

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Yes it seems so:

?- Z is float(51^10), T is Z-1.1904242382761301E17.
   Z = 1.19042423827613e+17, T = 0.0

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Can you show a Prolog query where this happens?
Also its not necessarily a display problem. For example
many Math.pow(double,double) implementations cannot

do the problem correctly. They cannot or do not round to
the theoretical optimum, they have inherently a higher error
than only one Unit in the last place (ULP). So a certain error

is to expect. You see this here:

/* Dogelog Player, JavaScript */
?- X is 51**10.
X = 1.19042423827613E17.

?- X is float(51^10).
X = 119042423827613010.0.

In the above the (**)/2 is Math.pow(double,double) and the
(^)/2 is exact bigint exponentiation. I took the pair (51,10)
from a list of pairs where (**)/2 and (^)/2 often disagree

based on Math.pow(double,double) typically being weak.

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

I have opened a separate ticket for printing. Because
this can get extremly confusing, if printing is not precise
enough. The ticket is here:

not precise enough float printing
#49

from trealla.

infradig avatar infradig commented on July 28, 2024

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

printing needs to satisfy. If this is not satisfied, its
very hard to debug other errors, it will "mask" other
errors, like erros or variations in arithmetic such

as (/)/2, (**)/2, (^)/2 and float/2:

read(write(X))) == X

in the 3.0 example its clear. In SWI-Prolog the result is
different. Try subtracting 3 from the division? The 1/10
example, I don't know, maybe better discuss it here:

not precise enough float printing
#49

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

Here you see SWI-Prolog computes another number,
the issue is currently discussed in SWI-Prolog forum.
They use mqr_get_d instead mqr_get_d_nearest or

somesuch is their problem. Also their a varying approachs to
realize (/)/2, either with divmod(A,B,...) or simply
(float)A/(float)B. Their system might also differ in this respect:

/* Trella Prolog */
?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890 - 3.
   N9 = 4.440892098500626e-16.

/* SWI-Prolog */
?- N9 is 370370367037037036703703703670 / 123456789012345678901234567890 - 3.
N9 = 0.

from trealla.

Jean-Luc-Picard-2021 avatar Jean-Luc-Picard-2021 commented on July 28, 2024

The (^)/2 error is gone, I now find:

Trealla Prolog (c) Infradig 2020-2022, v2.7.15
?- X is 51^10.
   X = 119042423827613001

And the rest is a printing artefact, as already observed:

?- X is 51^10, Z is float(X), Z =:= 1.19042423827613008E17.
   X = 119042423827613001, Z = 1.19042423827613e+17.

Closing this ticket.

from trealla.

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.