| Jacques Gélinas on Wed, 20 May 2020 00:47:42 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: Float Numbers with 200 digits |
> I need to know how to represent a float number in PARI
Here is the answer of professor GP2C from # gp2c-run tst.gp
========================= file tst.gp
x = 1e-100;
print("x = ",x);
=========================
========================= from file tst.gp.c
static GEN x;
/*End of global vars*/
void
init_tst(long prec) /* void */
{
x = pol_x(0);
x = strtor("1e-100", prec);
pari_printf("x = %Ps\n", x);
return;
}
================================
And this works!
================================
GP/PARI CALCULATOR Version 2.12.1
$ init_tst()
x = 1.0000 E-100
$
================================
Jacques Gélinas
De : Loïc Grenié <loic.grenie@gmail.com>
Envoyé : 19 mai 2020 17:03
À : Tiago Mendes <tiagovazmendes7@gmail.com>
Cc : pari-users <pari-users@pari.math.u-bordeaux.fr>
Objet : Re: Float Numbers with 200 digits
Hi,
On Tue 19 may 2020 at 04:10, Tiago Mendes wrote:
Hi guys,
I need to know how to represent a float number in PARI. To use integre i usually do :
GEN expoent = strtoi("1123213137")
To represent a number like 10^{-200} how should i do ?
Depending on what you precisely need, real_1 might be your friend:
\fun{GEN}{real_1}{long prec} create a \typ{REAL} equal to $1$ to \kbd{prec}
words of accuracy.
This creates a 1 with arbitrary precision. You can use it with
gdiv(real_1(200),powuu(10,300)) (this creates 10^{-300} with 200 digits
precision).
Hope this helps,
Loïc