2

I want to convert the text hello to ascii decimal in PARI/GP. After that I will concatenate the values.

I initialize a Vecsmall(hello), after that I run a loop to concatenate the ascii decimal values, I want to use this concatenated value to * by certain values. The value is now in String type, In Java, there is a Integer.parseInt() to convert the string to int. I wonder if there is a similar function in PARI/GP?

v=Vecsmall("hello");'
for (i = 1, length(v), text=Str(text,v[i]););
//is there any similar function like Integer.praseInt(text) in PARI?
Charles
  • 11,269
  • 13
  • 67
  • 105
user3820292
  • 310
  • 3
  • 19

1 Answers1

1

You can use eval

eval(text)

or else a combination of Vecsmall and fromdigits which is faster:

fromdigits(apply(n->n-49, Vec(text)))
Charles
  • 11,269
  • 13
  • 67
  • 105