Home Adobe Substance

Need help picking out specific digits out of a long number, within a function?

KnobbyNobbes
polycounter lvl 5
Offline / Send Message
KnobbyNobbes polycounter lvl 5
Hey all, I am in need of a little bit of math advice. I have a need to take a really big number (10+ digits) and to get specific digits out of it. From a separate site, I saw this :

a=1298
first2 = floor(a/100)
second2 = rem(a, 100)

in an example for trying to get the digits of the number 1298. But I'm not sure how this translates into getting, lets say, numbers 456 out of a larger number of 123456789. Unfortunately, I don't see a rem function, though I do see we have a floor function. Anyone have any idea how this translates to Designer?

Replies

  • oblomov
    Options
    Offline / Send Message
    oblomov polycounter lvl 8
    rem is the division remainder, also known as modulo (or modulus), and often represented in programming languages with the operator %. In Designer, the corresponding node is called modulo (in the "operator" list).
    To get 456 in 123456789 you would need to compute :
    456 = (123456789 / 1000)  % 1000
    and more generally, in base 10, to get a sequence x of n figures starting with the kth figure within a number y, you would need to do :
    x =  (y / (10^(k-1)))  % (10^n)
Sign In or Register to comment.