How to create vector (10^16 + 1, 10^16 + 2, … , 10^16 + 1000) using R?

Multi tool use
up vote
0
down vote
favorite
I would like to create the following vector (10^16 + 1, 10^16 + 2, ... , 10^16 + 1000).
But if I try it like this:
daten <- rep(1e+16,1000)
daten + 1:1000
It gives me just an approximation:
[1] 10000000000000000 10000000000000002 10000000000000004 10000000000000004
[5] 10000000000000004 10000000000000006 10000000000000008 10000000000000008
[9] 10000000000000008 10000000000000010 10000000000000012 10000000000000012
[13] 10000000000000012 10000000000000014 10000000000000016 10000000000000016
......
How can I get R to calculate more precise ?
Thank you
r precision mantissa
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
0
down vote
favorite
I would like to create the following vector (10^16 + 1, 10^16 + 2, ... , 10^16 + 1000).
But if I try it like this:
daten <- rep(1e+16,1000)
daten + 1:1000
It gives me just an approximation:
[1] 10000000000000000 10000000000000002 10000000000000004 10000000000000004
[5] 10000000000000004 10000000000000006 10000000000000008 10000000000000008
[9] 10000000000000008 10000000000000010 10000000000000012 10000000000000012
[13] 10000000000000012 10000000000000014 10000000000000016 10000000000000016
......
How can I get R to calculate more precise ?
Thank you
r precision mantissa
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How much more precise?
– Rich Scriven
Nov 10 at 16:20
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to create the following vector (10^16 + 1, 10^16 + 2, ... , 10^16 + 1000).
But if I try it like this:
daten <- rep(1e+16,1000)
daten + 1:1000
It gives me just an approximation:
[1] 10000000000000000 10000000000000002 10000000000000004 10000000000000004
[5] 10000000000000004 10000000000000006 10000000000000008 10000000000000008
[9] 10000000000000008 10000000000000010 10000000000000012 10000000000000012
[13] 10000000000000012 10000000000000014 10000000000000016 10000000000000016
......
How can I get R to calculate more precise ?
Thank you
r precision mantissa
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I would like to create the following vector (10^16 + 1, 10^16 + 2, ... , 10^16 + 1000).
But if I try it like this:
daten <- rep(1e+16,1000)
daten + 1:1000
It gives me just an approximation:
[1] 10000000000000000 10000000000000002 10000000000000004 10000000000000004
[5] 10000000000000004 10000000000000006 10000000000000008 10000000000000008
[9] 10000000000000008 10000000000000010 10000000000000012 10000000000000012
[13] 10000000000000012 10000000000000014 10000000000000016 10000000000000016
......
How can I get R to calculate more precise ?
Thank you
r precision mantissa
r precision mantissa
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 10 at 16:12
Harro Cyranka
832313
832313
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 10 at 16:03


Joshua
34
34
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Joshua is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How much more precise?
– Rich Scriven
Nov 10 at 16:20
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31
add a comment |
How much more precise?
– Rich Scriven
Nov 10 at 16:20
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31
How much more precise?
– Rich Scriven
Nov 10 at 16:20
How much more precise?
– Rich Scriven
Nov 10 at 16:20
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The Rmpfr
package allows you as much precision as you need. Create numbers using the mpfr
function, specifying the value + the number of bits of precision you need.
library(Rmpfr)
daten <- mpfr(1:1000, 120)
daten <- daten + mpfr(1e16, 120)
print(daten[1:5])
This yields the following:
5 'mpfr' numbers of precision 120 bits
[1] 10000000000000001 10000000000000002 10000000000000003 10000000000000004 10000000000000005
thank you very much
– Joshua
Nov 10 at 16:56
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The Rmpfr
package allows you as much precision as you need. Create numbers using the mpfr
function, specifying the value + the number of bits of precision you need.
library(Rmpfr)
daten <- mpfr(1:1000, 120)
daten <- daten + mpfr(1e16, 120)
print(daten[1:5])
This yields the following:
5 'mpfr' numbers of precision 120 bits
[1] 10000000000000001 10000000000000002 10000000000000003 10000000000000004 10000000000000005
thank you very much
– Joshua
Nov 10 at 16:56
add a comment |
up vote
1
down vote
accepted
The Rmpfr
package allows you as much precision as you need. Create numbers using the mpfr
function, specifying the value + the number of bits of precision you need.
library(Rmpfr)
daten <- mpfr(1:1000, 120)
daten <- daten + mpfr(1e16, 120)
print(daten[1:5])
This yields the following:
5 'mpfr' numbers of precision 120 bits
[1] 10000000000000001 10000000000000002 10000000000000003 10000000000000004 10000000000000005
thank you very much
– Joshua
Nov 10 at 16:56
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The Rmpfr
package allows you as much precision as you need. Create numbers using the mpfr
function, specifying the value + the number of bits of precision you need.
library(Rmpfr)
daten <- mpfr(1:1000, 120)
daten <- daten + mpfr(1e16, 120)
print(daten[1:5])
This yields the following:
5 'mpfr' numbers of precision 120 bits
[1] 10000000000000001 10000000000000002 10000000000000003 10000000000000004 10000000000000005
The Rmpfr
package allows you as much precision as you need. Create numbers using the mpfr
function, specifying the value + the number of bits of precision you need.
library(Rmpfr)
daten <- mpfr(1:1000, 120)
daten <- daten + mpfr(1e16, 120)
print(daten[1:5])
This yields the following:
5 'mpfr' numbers of precision 120 bits
[1] 10000000000000001 10000000000000002 10000000000000003 10000000000000004 10000000000000005
answered Nov 10 at 16:31


Edward Carney
92926
92926
thank you very much
– Joshua
Nov 10 at 16:56
add a comment |
thank you very much
– Joshua
Nov 10 at 16:56
thank you very much
– Joshua
Nov 10 at 16:56
thank you very much
– Joshua
Nov 10 at 16:56
add a comment |
Joshua is a new contributor. Be nice, and check out our Code of Conduct.
Joshua is a new contributor. Be nice, and check out our Code of Conduct.
Joshua is a new contributor. Be nice, and check out our Code of Conduct.
Joshua is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240770%2fhow-to-create-vector-1016-1-1016-2-1016-1000-using-r%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
g,J,TvfGMMDre,1 Z2TL,MopA M,tHSZvdM15SjMKau45rsT,CKv189e1uW8ie7KI fOjgVV,F8 FW7hrIehH03
How much more precise?
– Rich Scriven
Nov 10 at 16:20
R is not (at least out of the box) an arbitrary precision calculator. In your example you are dealing with floating point arithmetic. en.wikipedia.org/wiki/IEEE_754#Basic_formats
– jogo
Nov 10 at 16:21
@Rich Scriven: so that the last digit is correct
– Joshua
Nov 10 at 16:31