fpprintprec with bigfloats
- Subject: fpprintprec with bigfloats
- From: Edwin Woollett
- Date: Sat, 28 Mar 2009 11:29:40 -0700
On 3-28-09 Edwin Woollett wrote:
-------------------------------------
Using fpprintprec inside a block with
a bigfloat produces
results I don't understand.
------------------------------------------------------------
(%i1) fpprintprec : 8$
(%i2) bf1 : bfloat ( integrate ( exp(x), x, -1, 1 ) ), fpprec:45;
(%o2) 2.3504023b0
(%i3) bfprint (bf, fpp) :=
block( [fpprintprec ],
fpprintprec : fpp,
print ( " ", x, " ", bf ) )$
(%i4) for x : 10 thru 18 do bfprint ( bf1, x)$
10 2.350402387b0
11 2.3504023872b0
12 2.35040238728b0
13 2.350402387287b0
14 2.3504023872876b0
15 2.3504023872876b0
16 2.35040238728760291376476370119120163031143596b0
17 2.35040238728760291376476370119120163031143596b0
18 2.35040238728760291376476370119120163031143596b0
(%i5) ( fpprintprec : 50, print ( bf1 ) )$
2.35040238728760291376476370119120163031143596b0
--------------------------------------------
The number printed for fpp >= 16 is the 45 digit number
originally generated with bfloat.
===============================
I should have paid more attention to the manual.
Here is a version that works:
=================
(%i11) bfprint(bf,fpp) :=
block( [fpprec, fpprintprec ],
fpprec : fpp + 2,
fpprintprec : fpp,
print(" ",x," ",bf) )$
(%i13) for x:8 thru 21 do bfprint(bf1,x)$
8 2.3504023b0
9 2.35040238b0
10 2.350402387b0
11 2.3504023872b0
12 2.35040238728b0
13 2.350402387287b0
14 2.3504023872876b0
15 2.3504023872876b0
16 2.350402387287602b0
17 2.3504023872876029b0
18 2.35040238728760291b0
19 2.350402387287602913b0
20 2.3504023872876029137b0
21 2.35040238728760291376b0
==============
Ted Woollett