Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: ' How to control the format of the answer' topicStudent Support Forum > General > " How to control the format of the answer"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
07/09/13 5:14pm

Try this with very simple examples first, a dozen or two dozen digits, inspect the results, try various different numbers until you think you understand how this works and believe you can depend on it before you start doing bigger numbers. You can even peek at the contents of the data files outside of Mathematica to try to see what it is putting in them.

Every single character in this has a precise meaning to Mathematica, any tiny change will probably break this and you may not be able to figure out how to fix it. You can't substitute { or ( or [, you can't leave out or insert extra _, you can't swap upper and lower case, etc. and expect Mathematica to work.

Drop trailing digits and save pairs in a table

In[1]:= exportValueDigitTable[value_, numberOfDigits_] := Put[Transpose[{Range[numberOfDigits], First[RealDigits[value, 10, numberOfDigits]]}], "lista.dat"];
exportValueDigitTable[.122313132214, 4];

Get the data back and look for pairs {x, 2}

In[3]:= pairs = Get["lista.dat"];
Cases[pairs, {x_, 2}]

Out[4]= {{2, 2}, {3, 2}}

Restrict searching to the pairs from 1 to 2, look for pairs (x, 2} and save the index in a file

In[5]:= Put[Cases[Take[pairs, {1, 2}], {x_, 2} :> x], "listb.dat"];

URL: ,

Subject (listing for ' How to control the format of the answer')
Author Date Posted
How to control the format of the answer JD 07/08/13 9:40pm
Re: How to control the format of the answer Bill Simpson 07/09/13 5:14pm
Re: How to control the format of the answer Bill Simpson 07/10/13 11:27am
Re: Re: How to control the format of the answer JD 07/25/13 01:00am
Re: Re: Re: How to control the format of the a... Forum Modera... 07/25/13 12:49pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic