Hello,
There might be another problem with some of the numbers in the example.
R uses C's double numeric type and that means that the limit is around
16 decimal digits of precision. One of the numbers has 23, so there will
allways be loss of accuracy.
a <- 234235423.56
b <-
Putting back the context:
( We are not looking at this with Nabble.)
> When estimating values each determined similarly, and in which get to them
> by algebraic operations in some cases, are rounded with 0 decimal places and
> in other cases with 2 or 3 decimal places. What is happening?
> Than
For example
> a=12344.567
> a
[1] 12344.57
> b=234.567
> b
[1] 234.567
> a=234235423.56
> a
[1] 1.11e+20
> b=111.898
> b
[1] 112
>
--
View this message in context:
http://r.789695.n4.nabble.com/Number-of-decimal-places-tp4647549p4647552.html
Sent from the R he
When estimating values each determined similarly, and in which get to them
by algebraic operations in some cases, are rounded with 0 decimal places and
in other cases with 2 or 3 decimal places. What is happening?
Thank you.
--
View this message in context:
http://r.789695.n4.nabble.com/Numbe
nteger
multiple of the resolution, that is max-min=ineger*resolution. The bbox limits
must just be rounded to the same number of digits as the resolution and include
all available values, of course.
Best regards.
> Оригинално писмо
>От: arun
>Относно: Re: [R] nu
On Mon, Jul 09, 2012 at 07:52:18AM -0500, Jim Plante wrote:
> I don't know how significant this is, but WolframAlpha's value of pi
> disagrees with R's at about the 16th decimal:
>
> Wpi->3.141592653589793238462643383279502884197169399375105
> ..^
> Rpi->3.1415926535897931159
pi,digits=36)
> b
> [1] "3.14159265358979311599796346854418516"
>
> identical(a,b)
> [1] TRUE
>
>
> identical(a,signif(pi,digits=35))
> [1] FALSE
>
>
> A.K.
>
>
>
> - Original Message -
> From: Petr Savicky
> To: r-help@
> -Original Message-
> From: Martin Ivanov
> I have the longitudes (lon) and latitudes (lat), and I have a
> resolution (r), for example r = 0.004. The bounding box must
> have the same number of digits as resolution.
Surely the issue is not the particular numeric resolution of the n
ent: Sunday, July 8, 2012 2:21 PM
Subject: Re: [R] number of decimal places in a number?
On Sat, Jul 07, 2012 at 01:12:34PM +0100, Ted Harding wrote:
> I had thought of also (as well as my numerical routing) suggesting
> a "gsub()" type solution like Joshua's below, but held ba
On Sat, Jul 07, 2012 at 11:52:35AM +0300, Martin Ivanov wrote:
> Dear R users,
>
> I need a function that gets a number and returns its number of actual decimal
> places.
> For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400)
> should also return 2
> and so on. Is such funct
On Sun, Jul 08, 2012 at 11:39:22AM -0700, arun wrote:
> Hi Petr,
>
> I think sprintf and formatC are identical as it can round >22 decimal places
> as opposed to print and signif
> print(pi,digits=35)
Hi Arun:
Thank you for pointing this out. Funtion formatC()
is easier to use and uses the same
On Sat, Jul 07, 2012 at 01:12:34PM +0100, Ted Harding wrote:
> I had thought of also (as well as my numerical routing) suggesting
> a "gsub()" type solution like Joshua's below, but held back because
> the result could depend on how the number arose (keyboard input,
> file input, or from computatio
mod Ted's comments, I believe that for your situation (not too many digits
to represent, decimal point always present)
countDecDigits <-
function(x)nchar(sapply(strsplit(as.character(x),"\\."),"[",2))
is simple and should work. No need for regular expressions here.
-- Bert
On Sat, Jul 7, 2012
56237309514547462185873882845"
#using >22
x <- c("3.14", "3.142", "3.1400", "123456.123456789",
"123456789.123456789",formatC(pi,format="f",digits=35),formatC(sqrt(2),format="f",digits=50))
decimalnumcount(x)
#[1]
Dear Mr Harding,
Thank You very much for Your responsiveness.
>There would seem to be no clean general solution to this
>question. An important issue would be: What use do you
>want to put the result to?
I need this trick for the following task.
I am writing a function which has to determin
I had thought of also (as well as my numerical routing) suggesting
a "gsub()" type solution like Joshua's below, but held back because
the result could depend on how the number arose (keyboard input,
file input, or from computation within R).
However, I now also realise that (again because of bina
Hi Martin,
Ted is spot on about the binary representation. A very different
approach from his would be to convert to character and use regular
expressions:
## the example numbers in a vector
x <- c(3.14, 3.142, 3.1400, 123456.123456789, 123456789.123456789, pi, sqrt(2))
nchar(gsub("(.*\\.)|([0]
On 07-Jul-2012 08:52:35 Martin Ivanov wrote:
> Dear R users,
>
> I need a function that gets a number and returns its number of
> actual decimal places.
> For example f(3.14) should return 2, f(3.142) should return 3,
> f(3.1400) should also return 2 and so on. Is such function already
> availabl
Dear R users,
I need a function that gets a number and returns its number of actual decimal
places.
For example f(3.14) should return 2, f(3.142) should return 3, f(3.1400) should
also return 2
and so on. Is such function already available in R? If not, could you give me a
hint how to achieve
19 matches
Mail list logo