Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a sequence from big power numbers

I'm trying to create a sequence of integers from big numbers and couldn't find a way to suceed. Is there a way to do this ?

I tried :

(2^128):(2^128+3000) which returns: [1] 3.402824e+38

So I tried to use the gmp library :

library(gmp)
as.bigz(2^128):as.bigz(2^128+3000)

and got

messages: 1: In as.bigz(2^128):as.bigz(2^128 + 3000) :   numerical
expression has 32 elements: only the first used 2: In
as.bigz(2^128):as.bigz(2^128 + 3000) :   numerical expression has 32
elements: only the first used
like image 203
Pasdenom Avatar asked Jan 28 '26 09:01

Pasdenom


2 Answers

Add your sequence to your "big number":

library(gmp)
as.bigz(2^128) + 0:3000
Big Integer ('bigz') object of length 3001:
[1] 340282366920938463463374607431768211456 340282366920938463463374607431768211457 
[3] 340282366920938463463374607431768211458 340282366920938463463374607431768211459
[5] 340282366920938463463374607431768211460 340282366920938463463374607431768211461
# ...
like image 120
M-- Avatar answered Jan 30 '26 00:01

M--


We can use seq

library(gmp)
seq(as.bigz(2^128), length.out = 3001)
like image 28
akrun Avatar answered Jan 30 '26 01:01

akrun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!