|
[Date Index]
[Thread Index]
[Author Index]
Re: Printing numbersDavid Bailey,dbaileyconsultancy.co.uk
- To: mathgroup at smc.vnet.net
- Subject: [mg54702] Re: Printing numbersDavid Bailey,dbaileyconsultancy.co.uk
- From: Steve Gray <stevebg at adelphia.net>
- Date: Sun, 27 Feb 2005 01:29:44 -0500 (EST)
- References: <cvhhj7$rdr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Actually PaddedForm is closest to what I wanted. I wasn't aware of it due to conscientious but not
quite adequate searching in Help and in 4 books. Thanks to everyone who answered.
Steve Gray
On Wed, 23 Feb 2005 09:15:19 +0000 (UTC), David Bailey <dave at Remove_Thisdbailey.co.uk> wrote:
>Steve Gray wrote:
>> 1. Can anyone tell me why these results are what they are? Neither answer is what I would expect,
>> which is 10. The two strings are the same length.
>>
>> Print[StringLength[ToString[123.456789]], " ",
>> StringLength[ToString[1234567.89]]];
>> 7 22
>>
>> 2. Is there a simple, easily available or self-evident way to get numbers printed out such that the
>> total number of spaces occupied by the print before the decimal point is some fixed, user-specified
>> amount, the number of spaces occupied after the decimal point is a different user-specified amount,
>> and the number of spaces following the number is a third user-specified amount. The goal is to
>> easily produce aligned columns of numerical printing, which would seem to be the most trivial task
>> in neat number printing.
>> For example if the function is called fprint, fprint[345.678,4,5,6] would print 4 spaces
>> followed by 5 character positions to the left of the point (00345 or (2 spaces)" 345", specified by
>> another argument), and 6 to its right. So fprint[345.678,4,5,6] would print (4 spaces)(2
>> spaces)"345.678"(3 spaces), or if desired (4 spaces)(2 spaces)"345.678000"(no spaces), the total
>> taking up 16 positions. Also fprint[-345.678,4,5,6] would print (4 spaces)(1 space)"-345.678"(3
>> spaces), also taking 16 positions, with the decimal points aligned with the first example.
>> Help is not that helpful, implying that I have to write one or find it somewhere. As I
>> recall, C provides an easy way to do this by setting arguments to Print.
>> Leads would be appreciated.
>>
>> Steve Gray
>>
>>
>
>Lookup NumberForm, ScientificForm and EngineeringForm
>
>
>David Bailey
>dbaileyconsultancy.co.uk
Prev by Date:
Re: Re: Computing Complex Series Solution using Mathematica
Next by Date:
Re: Re: nonlinear differential equation
Previous by thread:
Re: Printing numbersDavid Bailey,dbaileyconsultancy.co.uk
Next by thread:
Graphic resizing problem Linux notebook
|