RE: Number Formatting
- To: mathgroup at smc.vnet.net
- Subject: [mg17733] RE: [mg17714] Number Formatting
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Tue, 25 May 1999 02:15:16 -0400
- Sender: owner-wri-mathgroup at wolfram.com
David Park wrote: ----------------- Sometimes I like to use N to set the display precision of a number. However it seems to have strange behavior. TableForm[Table[N[248713.11673961558`, i], {i, 1, 9}]] 300000. 250000. 249000. 2.487 x 10^5 2.4871 x 10^5 248713. 248713.1 248713.12 248713.117 Why is the first entry rounded the wrong way? Why the switch into and out of exponent format? Except for the first three entries one might say it only shows the number of digits in the precision. But then why not use exponent notation for the first three entries also? When NumberForm is used instead of N, the rounding is correct, there are no exponent forms used, and there are NumberForm::sigz warning messages when there are trailing nonsignificant zeros. Is the lesson that N is not really meant for number formatting, and N[expr, 1] should never be used? In some fields, one place precision is quite respectable! ----------------- Obviously the kernel uses some criteria to decide whether to use decimal notation or scientific notation. I don't know exactly what this criteria is or how a user can change it. It would be nice if the user could control this criteria. When you use N[expr,i] you change the internal representation of the data. When you use NumberForm[expr, i] the output will have the head NumberForm. Do you want to only affect the way the data is displayed? If that's the case try the following: - Select a cell you want to change. - Make the menu selection (Format | Option Inspector). - Chose (Show option values for - Selection). - Use Lookup to find the PrintPrecision option. - Change the setting of this option to the value you want. Now all machine precision numbers in the cell(s) you had selected will be displayed using the number of digits you indicated. It seems this has no effect on arbitrary precision numbers. --------------- On a related subject consider the following: In[1]:= numb = N[ 749725819 + 100*Tan[355/226], 4]; {numb, Precision[numb], MachineNumberQ[numb]} Out[1]= {1.086, 16, True} It seems the kernel used machine precision arithmetic above. I think it should use arbitrary precision and give the following output. {0.4674, 4, False} I don't consider this a bug. I consider it a design decision I don't like. ----------------- Regards, Ted Ersek