MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: problems with N[]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg38708] Re: problems with N[]
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Mon, 6 Jan 2003 03:42:59 -0500 (EST)
  • References: <av94u6$sb9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

With n <=  $MachinePrecision (=16 on my machine)  N[n,p] will give a machine
number
    N[Pi,4]

        3.14159

    Precision[%]

        16

Using SetPrecision we can specify precision 4

     SetPrecision[Pi,4]

            3.142

    Precision[%]

        4

However, NumberForm (which may be looked up in the Help Browser) allows us
to control the display in detail:

    NumberForm[N[Pi],4]

        3.142

Even though we have

    Precision[%]

        16


--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"1.156" <rob at piovere.com> wrote in message news:av94u6$sb9$1 at smc.vnet.net...
> I'm getting a numerical output which has about 12 significant digits.  I
wanted to give a printout to someone and I need only 4 significant digits
(otherwise it represents a result to precise).
>
> I thought that was what N[] was for so I put out N[result,4].
>
> For some reason I still get 12 digits displayed.  I looked through he help
material and it says
> "n must lie between $MinPrecision and $MaxPrecision. $MaxPrecision can be
set to Infinity. "
> I checked and these numbers are 0 and 10^6, respectively.
>
> So, I gave up on N[] and tried Ceiling[10000*result]/10000 and damn if I
didn't get "6/625"
> for an answer.
>
> I want to display a decimal result with 4 significant digits, can anyone
tell me how to do it?
>
> Thanks.
>




  • Prev by Date: Irreducible Polynomial over GF(2)
  • Next by Date: Re: Design problem in 4.2?
  • Previous by thread: Re: problems with N[]
  • Next by thread: Re: problems with N[]