Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10385

Re: Converting from string to real

From "Kevin J. McCann" <kjm@KevinMcCann.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Converting from string to real
Date 2012-06-07 09:26 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jqps4q$2j2$1@smc.vnet.net> (permalink)
References <jqn5mn$her$1@smc.vnet.net>

Show all headers | View raw


This is an output formatting issue, and I will admit that it is 
annoying. Note:

ToExpression["109266.75"]-109266.75

gives zero. So, the answer is correct, it is just that Mathematica formats the 
output by rounding it. I am not sure how to make it show the way you 
want in an easy fashion; however, this works

NumberForm[ToExpression["109266.75"],10]

but this is a formatted output "for your eyes only", i.e. DON'T do 
something like

b = NumberForm[ToExpression["109266.75"],10]

and then try to use b as a number.

Kevin

On 6/6/2012 4:51 AM, fcaleyo wrote:
> Hi guys, I've got a problem with ToExpression[].
> It seems to round large real numbers off, e.g.
> ToExpression["109266.75"] returns 109267., still a real, yet not exactly what the original string meant.
> Any idea to solve this?
> Many thanks
> fcaleyo
>
>
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Converting from string to real fcaleyo <fcaleyo@gmail.com> - 2012-06-06 08:51 +0000
  Re: Converting from string to real Szabolcs Horvát <szhorvat@gmail.com> - 2012-06-07 09:24 +0000
  Re: Converting from string to real A Retey <awnl@gmx-topmail.de> - 2012-06-07 09:24 +0000
  Re: Converting from string to real "Kevin J. McCann" <kjm@KevinMcCann.com> - 2012-06-07 09:26 +0000
  Re: Converting from string to real Peter Breitfeld <phbrf@t-online.de> - 2012-06-07 09:27 +0000
  Re: Converting from string to real "Nasser M. Abbasi" <nma@12000.org> - 2012-06-07 09:16 +0000

csiph-web