Re: formatting float output



Mine looked slightly different than yours, but when I copied your
verbatim

?- fib( 64, F ).

F = 1.06102e+13

Yes

Using SWI-Prolog 5.2.13

Must be a difference between the old one on my school computers and
5.6.23

It's not hugely important, it does print it out in full when I use
format for a float, but it's very annoying anyway

Thanks for all your attention!

Markus Triska wrote:
"Jakanapes" <Jakanapes@xxxxxxx> writes:

I can use format( '~f', [F]) to get the full precision of the number as
a float, but I'd rather get it as an integer.

Is this with the explicit formula? With integer additions only, floats
shouldn't arise in recent SWI. Using the arithmetic function "round":

fib(N, F) :- S5 is sqrt(5), F is round((1/S5)*((1+S5)/2)^N).

?- fib(64, F).

F = 10610209857723

Don't use this version for (all but finitely many) larger N.

All the best! -- Markus Triska

.