Re: approximation
- To: mathgroup at smc.vnet.net
- Subject: [mg79442] Re: approximation
- From: dimitris <dimmechan at yahoo.com>
- Date: Fri, 27 Jul 2007 05:42:50 -0400 (EDT)
- References: <f89t1u$9af$1@smc.vnet.net>
On 26 , 13:29, giorgioru... at gmail.com wrote: > hello. My question is very very easy. > I have got a variabile as "a" and i want to print his approximated > value with n decimal digit. > > a=1.56068376362920545943; > Print["The value is : ", 1.6]; > or > Print["The value is : ", 1.56]; > > Is there anyone who can help me ? > thanks > Giorgio In[106]:= a=1.56068376362920545943; In[108]:= Print[N[a, 3]] >From In[108]:= 1.56 Watch that In[113]:= N[a,3]//InputForm Out[113]//InputForm= 1.5606837636292054594`3.000000000000001 As an application In[116]:= (Print[N[a, #1]] & ) /@ Range[Length[First[RealDigits[a]]]]; >From In[116]:= 2. >From In[116]:= 1.6 >From In[116]:= 1.56 >From In[116]:= 1.561 >From In[116]:= 1.5607 >From In[116]:= 1.56068 >From In[116]:= 1.560684 >From In[116]:= 1.5606838 >From In[116]:= 1.56068376 >From In[116]:= 1.560683764 >From In[116]:= 1.5606837636 >From In[116]:= 1.56068376363 >From In[116]:= 1.560683763629 >From In[116]:= 1.5606837636292 >From In[116]:= 1.56068376362921 >From In[116]:= 1.560683763629205 >From In[116]:= 1.5606837636292055 >From In[116]:= 1.56068376362920546 >From In[116]:= 1.560683763629205459 >From In[116]:= 1.5606837636292054594 Regards Dimitris