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











up vote
0
down vote

favorite
1












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










share|improve this question









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















up vote
0
down vote

favorite
1












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










share|improve this question









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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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










share|improve this question









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






share|improve this question









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.











share|improve this question









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.









share|improve this question




share|improve this question








edited Nov 10 at 16:12









Harro Cyranka

896313




896313






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


















  • 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












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





share|improve this answer





















  • thank you very much
    – Joshua
    Nov 10 at 16:56











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Joshua is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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















Required, but never shown

























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





share|improve this answer





















  • thank you very much
    – Joshua
    Nov 10 at 16:56















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





share|improve this answer





















  • thank you very much
    – Joshua
    Nov 10 at 16:56













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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 16:31









Edward Carney

92926




92926












  • 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




thank you very much
– Joshua
Nov 10 at 16:56










Joshua is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma