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

0 Members and 1 Guest are viewing this topic.

Offline NonstickAtom785

  • LV3 Member (Next: 100)
  • ***
  • Posts: 78
  • 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]
;base->B
;Ans is the string to convert
sum(seq(B^(length(Ans)-A)inString("123456789ABCDEF",sub(Ans,A,1)),A,1,length(Ans

This code is smaller than the method using For() but I haven't tested it speed wise.

EDIT: I have made this routine smaller. I did this a while back and posted it on Cemetech just forgot to cross-post it. :)
« Last Edit: February 26, 2021, 01:04:57 pm by NonstickAtom785 »
Grammer2 is Good!