Re: [R] rounding off problem.....

2019-03-08 Thread Kevin Thorpe
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.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
 

On 2019-03-08, 7:39 AM, "R-help on behalf of akshay kulkarni" 
 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@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.


__
R-help@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.


Re: [R] rounding off problem.....

2019-03-08 Thread Eric Berger
"Is there any way ..."
Two quick answers:
1. using base R functions and data types the answer is 'no' - a double
(i.e. numeric) contains about 15 significant digits.
So 5.678e-100 is fine but   0.01 + 5.678e-100 will keep the
.0100  as the significant digits and "drop" the digits 80 or so
places further to the right.
2. there are packages that provide for arbitrary precision calculations
see R CRAN package Rmpfr
 https://cran.r-project.org/web/packages/Rmpfr/vignettes/Rmpfr-pkg.pdf

HTH,
Eric

On Fri, Mar 8, 2019 at 2:39 PM akshay kulkarni 
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@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.
>

[[alternative HTML version deleted]]

__
R-help@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.