Re: Annoying Little Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg24739] Re: [mg24701] Annoying Little Problem
- From: BobHanlon at aol.com
- Date: Wed, 9 Aug 2000 02:31:42 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 8/4/2000 1:30:31 AM, ayrton at rac1.wam.umd.edu writes:
>I'm having an annoying little problem with version 4.0.1.0. I wrote the
>
>following info in a notebook and ran it:
>
>Clear[v2]
>v2 = {4, 0, -6}
>N[Sqrt[v2.v2]]
>N[Sqrt[v2.v2], 3]
>
>Now the third line gives me 7.2111 but the fourth line gives me the
>same instead of 7.21. Does anyone have any idea what may be the problem?
>
>Am I doing something wrong?
>
?N
"N[expr] gives the numerical value of expr. N[expr, n] attempts to give a \
result with n-digit precision."
Note that while this indicates the precision of the result, it does not say
anything about how the result is printed.
Clear[v2]; v2 = {4, 0, -6};
Table[NumberForm[N[Sqrt[v2.v2]], k], {k, 7}]
{"7.", "7.2", "7.21", "7.211", "7.2111", "7.2111", "7.211103"}
Note that for k=5 and k=6 the display is the same, i.e., the trailing zero is
suppressed for k=6. To display the trailing zero
Table[NumberForm[N[Sqrt[v2.v2]], {k, k - 1}, NumberPadding -> {"", "0"}], {k,
7}]
{"7.", "7.2", "7.21", "7.211", "7.2111", "7.21110", "7.211103"}
Bob Hanlon