Comments (12)
from trealla.
from trealla.
Yes it seems so:
?- Z is float(51^10), T is Z-1.1904242382761301E17.
Z = 1.19042423827613e+17, T = 0.0
from trealla.
from trealla.
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.
from trealla.
from trealla.
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.
from trealla.
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.
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.
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)
- Segmentation Dump with NOFFI=1 NOSSL=1 NOTHREADS=1 ISOCLINE=1 Enabled HOT 1
- arg/3 + string weirdness HOT 2
- freeze/2 not playing well with negation HOT 6
- Module visibility for attributes incorrect? HOT 2
- Callligraphic script not unparsed like it is parsed?
- matrix: mat_lup_det/2 segfault HOT 4
- Apropos reading/writing. Trying to read from a named pipe: HOT 4
- Loading nonexistent shared lib should be an error HOT 10
- GSL: Error handling HOT 4
- GSL: matrix no-size (0x0) segfault HOT 4
- GSL: Info+Question HOT 14
- Support CLP(B) HOT 10
- Superflous parenthesis for fy mode HOT 3
- GSL: wrong sized matrix segfault
- GSL: library/gsl.pl hard-coded size
- GSL: result inoperative HOT 12
- pl_yield_at can cause some undesirable side effects HOT 10
- getting answers that are just a variable HOT 7
- [] not an atom that can be used as an operator HOT 10
- GSL: Bugs HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trealla.