[R] rounding off problem.....

Kevin Thorpe kev|n@thorpe @end|ng |rom utoronto@c@
Fri Mar 8 14:04:41 CET 2019


I'm no expert in R internals or floating point computation, however, two things come to mind.

First, I suspect the exact value is stored. It is just the printing that looks rounded. That is likely because 0.001 completely dominates the rest. To print in full precision, you would need over 200 digits for some of your values.

Second, you may be pushing the limits of precision. It seems to me your original values are indistinguishable from zero. If they really represent materially different values, you might want to rescale them to improve computational reliability. 

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.thorpe using utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2019-03-08, 7:39 AM, "R-help on behalf of akshay kulkarni" <r-help-bounces using r-project.org on behalf of akshay_e4 using hotmail.com> wrote:

    dear members....
                                     here is a piece of my code:
    
    > tail(YLf14,15)
     [1] 5.706871e-217 2.563877e-218 2.823295e-218 2.694622e-222 1.777409e-226
     [6] 1.134403e-201 5.269464e-215 2.272121e-219 2.794970e-223 1.630978e-187
    [11] 1.721529e-213 5.859815e-178 4.842612e-222 1.333685e-193 1.256051e-174
    > YLf16 <- YLf14 + 0.001
    > tail(YLf16,15)
     [1] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001
    [13] 0.001 0.001 0.001
    
    Is there any way to avoid the rounding off of YLf16 to 0.001, and take exact values?
    
    very many thanks for your time and effort......
    yours sincerely,
    AKSHAY M KULKARNI
    
    
    	[[alternative HTML version deleted]]
    
    ______________________________________________
    R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
    



More information about the R-help mailing list