DisplayForm changes precission
- To: mathgroup at smc.vnet.net
- Subject: [mg47552] DisplayForm changes precission
- From: Mario Drobics <mario.drobics at scch.at>
- Date: Thu, 15 Apr 2004 05:02:18 -0400 (EDT)
- Organization: Johannes Kepler Universitaet Linz
- Sender: owner-wri-mathgroup at wolfram.com
I am trying to create a GridBox to display some numbers. When applying
GridBox, however, the precission changes and the output gets unreadable.
Any ideas why this is happening?
Code:
(* round to prec digits *)
NRound[x_, prec_Integer:0] := MapAll[If[NumericQ[#],
N[Round[#*10^prec]/(10^prec)], #] &, x];
(* everything ok here *)
NRound[array, 2] // FullForm
List[List[
7.`, 0.`, 11.`, 18.`, 34.`, 1.`, 0.13`], List[7.`, 0.`, 11.`, 18.`,
34.`,
1.`, 0.13`], List[
9.`, 0.`, 25.`, 34.`, 18.`, 1.`, 0.17`], List[26.95`, 7.95`, 7.05`,
34.`,
18.`, 0.77`, 0.52`], List[29.`, 11.5`, 5.`, 34.`, 18.`, 0.72`, 0.56`],
List[31.`, 11.5`, 3.`, 34.`, 18.`, 0.73`, 0.6`]]
(* this also works *)
NRound[array /. Obj`CompResItem -> List, 2] // TableForm
\!\(\*
TagBox[GridBox[{
{"7.`", "0.`", "11.`", "18.`", "34.`", "1.`", "0.13`"},
{"7.`", "0.`", "11.`", "18.`", "34.`", "1.`", "0.13`"},
{"9.`", "0.`", "25.`", "34.`", "18.`", "1.`", "0.17`"},
{"26.95`", "7.95`", "7.05`", "34.`", "18.`", "0.77`", "0.52`"},
{"29.`", "11.5`", "5.`", "34.`", "18.`", "0.72`", "0.56`"},
{"31.`", "11.5`", "3.`", "34.`", "18.`", "0.73`", "0.6`"}
},
RowSpacings->1,
ColumnSpacings->3,
RowAlignments->Baseline,
ColumnAlignments->{Left}],
Function[ BoxForm`e$,
TableForm[ BoxForm`e$]]]\)
(* this does not work!!! *)
GridBox[
NRound[array /. Obj`CompResItem -> List, 2]
] // DisplayForm
\!\(\*
TagBox[GridBox[{
{"7.", "0.0", "11.", "18.", "34.", "1.", ".13"},
{"7.", "0.0", "11.", "18.", "34.", "1.", ".13"},
{"9.", "0.0", "25.", "34.", "18.", "1.", ".17000000000000001"},
{"26.949999999999999", "7.9500000000000002",
"7.0499999999999998", "
34.", "18.", ".77000000000000002", ".52000000000000002"},
{"29.", "11.5", "5.", "34.
", "18.", ".71999999999999997", ".56000000000000005"},
{"
31.", "11.5", "3.", "34.", "18.", ".72999999999999998", \
".59999999999999998"}
}],
DisplayForm]\)