No, it's not a subset. mpq is rational numbers; these will of course work the way you want it if you set q in p/q to something useful, like 1000000. mpf is a true floating point, and will work like floats in Pike.
It's more useful if you want to play with *floats* without having to worry about large numbers, for instance 1e(1e100) will work nicely in mpf, but not very nicely in mpq. :-)
Both mpq and mpf support seems limited, though. Neither of them have "pow".
there is a website where you can download a few megabytes worth of digits. though atm i am more interrested in an algorithm to generate prime numbers actually... (but thats another topic)
next_prime might be useful? :)
| > 42->next_prime(); | Result: 43
/ Mirar
Previous text:
2003-02-25 11:46: Subject: Re: Do we have a floatingpoint bug?
On Tue, Feb 25, 2003 at 11:30:01AM +0100, Mirar @ Pike developers forum wrote:
You don't happen to have a Pi-generating algorithm around? :)
there is a website where you can download a few megabytes worth of digits. though atm i am more interrested in an algorithm to generate prime numbers actually... (but thats another topic)
Gmp.mpf("3.1415926",32*256,10);
ahh, a string. and i just noticed this: Gmp.mpf(Gmp.mpq(31415926,10000000)); also works.
thanks.
sprintf %f and cast to string is broken for mpf, so I guess you'll have to do something else (cast to float?).
wait for the bug to get fixed ;-) considering that mpf is just a subset of mpq the latter will do fine
/ Brevbäraren