I have started using maxima
just a few weeks ago (actually I have just used it a few times) with the wxMaxima
interface for OS X.
I have tried to find a solution for this around the web, but maybe because I am blind or maybe because I do not have much experience in searching in the official documentation of maxima, I have not find a concrete solution yet.
How do I approximate a number to a n
number of decimal places? For example, if I use float(22/7)
, it gives me this huge number 3.142857142857143
, but I just want for example to approximate it to the 3rd decimal place 3.143
.
fpprec
controls the actual number of significant digits in a Maxima bigfloat. That applies only to bigfloats and not to ordinary (fixed precision, IEEE 754) floats.
See also fpprintprec
which controls how many digits are printed, which applies to bigfloats and to ordinary floats alike. So another solution for you is:
(%i1) fpprintprec : 4 $
(%i2) float (22/7);
(%o2) 3.143