From: Simon on 27 May 2010 06:45 Nice! I don't think that it's a "bug" but it is a little unexpected. ToString produces a kind of "pretty print" output, e.g. ToString[1/3] yields an string that prints as fraction: "1\n-\n3". This is controlled by the FormatType option. By default it is OutputForm. If you want a string that you can turn back into an expression, try ToExpression[ToString[1/3, InputForm]] This should probably be included in the "Possible Issues" section of the documentation.... Simon On May 26, 7:09 pm, James Stein <mathgr...(a)stein.org> wrote: > Evaluating: > > ToExpression [ ToString [ 1/3 ] ] > > I did not expect negative three! > > Bug? or a lack in my understanding?
From: Murray Eisenberg on 27 May 2010 06:45 I don't understand the result either, but I have a clue: FullForm[ToString[1/3]] "1\n-\n2" I would actually expect the result to be a pair of output cells, namely: 1 -2 On 5/26/2010 7:10 AM, James Stein wrote: > Evaluating: > > ToExpression [ ToString [ 1/3 ] ] > > I did not expect negative three! > > Bug? or a lack in my understanding? > > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
From: Bill Rowe on 27 May 2010 06:46 On 5/26/10 at 7:10 AM, mathgroup(a)stein.org (James Stein) wrote: >Evaluating: >ToExpression [ ToString [ 1/3 ] ] >I did not expect negative three! >Bug? or a lack in my understanding? Do ToCharacterCode[ToString[1/3]] and you will find the character code for 1, - and 3 all followed by line termination characters. On Unix or Mac OS this is a line feed character and possibly different on Windows. In any case, this is seen as an implicit multiply yielding -3.
From: David Bailey on 28 May 2010 07:20 On 27/05/10 11:45, Murray Eisenberg wrote: > ToExpression [ ToString [ 1/3 ] ] And indeed, ToExpression[ToString[1/3,InputForm]] works as expected! David Bailey www.dbaileyconsultancy.co.uk
First
|
Prev
|
Pages: 1 2 Prev: Could you prove this proposition:the i-th prime gap Next: Integrate expression |