Please post in plain text. You assume significant risk that we will
receive a corrupt version of your code if you fail to do this.
As far as I can see, the gmp package does not currently support a raw
interface to create bigz values. Here is my workaround:
####
plaintext <- "Rossetta Code"
stringtoasciihex <- function( s ) {
vs <- strsplit( s, "", fixed = TRUE )[[ 1 ]]
asc <- sapply( vs, function( C ) as.character( charToRaw( C ) ) )
paste( c( "0x", asc ), collapse="" )
}
gmp::as.bigz( stringtoasciihex( plaintext ) )
###
On Sat, 17 Aug 2019, Martin M?ller Skarbiniks Pedersen wrote:
Hi,
I am trying to make a R version a RosettaCode task involving big number.
More precise, I am trying to convert the c-solution
http://rosettacode.org/wiki/RSA_code#C
to R.
These two lines in C gives me problems:
const char *plaintext = "Rossetta Code";
mpz_import(pt, strlen(plaintext), 1, 1, 0, 0, plaintext);
I have tried:
library(gmp)
plaintext <- "Rossetta Code"
as.bigz(charToRaw(plaintext))
and
library(gmp)
plaintext <- "Rossetta Code
as.big(split(plaintext,""))
Thanks for any help/suggestions
Regards
Martin M. S. Pedersen
[[alternative HTML version deleted]]
______________________________________________
R-help@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.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
______________________________________________
R-help@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.