Re: These Simple Four Lines of Mathematic Confound Me -- Bug?
- To: mathgroup at smc.vnet.net
- Subject: [mg121437] Re: These Simple Four Lines of Mathematic Confound Me -- Bug?
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Thu, 15 Sep 2011 04:39:13 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j4prlp$fne$1@smc.vnet.net>
On 14/09/2011 10:20, James Stein wrote: > I've boiled this puzzlement down to bare bones: > > Clear [ g ]; > g := { NumberForm [ 13.0, { 5, 3 } ] }; > g > % // N > > Line 3 gives the output: {13.0} (as expected) > Line 4 gives the output: {13.} but first gives this error message: > > NumberForm::iprf : "Formatting specification =91=99{\"5.\", \"3.\"} should be \ > a positive integer or a pair of positive integers." > > Line 4 seems to cause 'g' to be called. Why? > And how has the formatting spec {5,3} been converted away from integers? > (running Mathematica 8.0.1.0 on a Macintosh) > Look at g//FullForm You will see that NumberForm (like MatrixForm and TableForm, and a number of other functions) becomes part of the expression. Your specific error happens because the numbers 5 an3 get converted to Reals, which are not suitable for NumberForm. The answer is to never (at least unless you really know what you are doing) assign anything to an expression involving any of the above functions (NumberForm, etc.), or embed those functions in more calculations. David Bailey http://www.dbaileyconsultancy.co.uk