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]]
"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 .0100000000000000 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 <akshay_e4 at 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 at 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]]
dear EB, I checked the Rmpfr package. Thats exactly what I needed....! Thanks a lot. very many thanks for your time and effort, yours sincerely, AKSHAY M KULKARNI ________________________________ From: Eric Berger <ericjberger at gmail.com> Sent: Friday, March 8, 2019 6:31 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] rounding off problem..... "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 .0100000000000000 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 <akshay_e4 at hotmail.com<mailto:akshay_e4 at 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 at r-project.org<mailto:R-help at 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]]