MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How can I transform the number of 123.456 into "123.456"?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26662] Re: [mg26515] How can I transform the number of 123.456 into "123.456"?
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Wed, 17 Jan 2001 00:47:17 -0500 (EST)
  • References: <200101010732.CAA09656@smc.vnet.net> <92uqmk$drv@smc.vnet.net> <93r81o$4rp@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Drago

> Can somebody explain the behaviour of RealDigits [89087.345]  - the last
number in the digits list!!!
>
> Greetings from Croatia,
> Drago Ganic

RealDigits [89087.345]

{{8, 9, 0, 8, 7, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1}, 5}

I have not sorted this out competely to my satisfaction but:

The HelpBrowser tells us that

"RealDigits[x] normally returns a list of digits whose length is equal to
Precision[x] "
(in this case the precision is 16).

It seems that the 1 is due to 89087.345 being converted to binary and back

We see more of what has happend with

RealDigits [89087.345, 10, 20]

{{8, 9, 0, 8, 7, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 1, 6, 6, 7}, 5}

To mitigate this, up to a point, we can  use

89087.345`n

Which will pad with zeros:

{{8, 9, 0, 8, 7, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0}, 5}

Please see the NumericsReport under Getting Started/Demos > Demos


--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565





  • Prev by Date: Re: Cause of $ErrorLink message in EXCEL/Mathematica
  • Next by Date: Re: Calling Mathematica-4.0 from C Code.
  • Previous by thread: Re: How can I transform the number of 123.456 into "123.456"?
  • Next by thread: Re: How can I transform the number of 123.456 into "123.456"?