Author Topic: Converting Base to Decimal with seq()  (Read 80 times)

0 Members and 1 Guest are viewing this topic.

Online NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 62
  • Rating: +4/-0
  • Just live life. Cal-cu-lat-or style!
    • View Profile
Converting Base to Decimal with seq()
« on: September 01, 2020, 01:39:14 pm »

Code: [Select]
;B=Base
;v="length(Ans
;Ans is a string to convert
 
length(Ans->v
sum(seq(B^(v+1-n)inString("123456789ABCDEF",sub(Ans,n,1),1)/B,n,1,v


The size would be smaller if you didn't use the italic n but it would also be slower.
This code is smaller than the method using For() but I haven't tested it speed wise.
Grammer2 is Good!