Re: formatting float output
- From: "Jakanapes" <Jakanapes@xxxxxxx>
- Date: 16 Nov 2006 12:12:40 -0800
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
.
- Follow-Ups:
- Re: formatting float output
- From: Markus Triska
- Re: formatting float output
- References:
- formatting float output
- From: Jakanapes
- Re: formatting float output
- From: Markus Triska
- Re: formatting float output
- From: Jakanapes
- Re: formatting float output
- From: Jan Wielemaker
- Re: formatting float output
- From: Jakanapes
- Re: formatting float output
- From: Markus Triska
- formatting float output
- Prev by Date: Re: formatting float output
- Next by Date: Re: formatting float output
- Previous by thread: Re: formatting float output
- Next by thread: Re: formatting float output
- Index(es):