playMaker

Author Topic: Help with breaking up a 3 digit int into 3 separate integers [SOLVED]  (Read 1799 times)

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Hello,
I need help with breaking up a 3 digit int into 3 separate integers.
For example: myInt = 150
For my purpose, I need to get an int for each place value. So from 150 i'd like to get ints for 1 and 5 and 0.

Would this be possible at all with playmaker?
 :-\
Thanks
« Last Edit: June 15, 2014, 09:41:07 AM by Sarcophagav »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help with breaking up a 3 digit int into 3 separate intagers
« Reply #1 on: June 11, 2014, 07:53:03 AM »
Hi,

 yes totally, the easiest way, is to convert your int into a string, then take each character, and back into an int.

use "get substring" to get to a particular character, and use "iterate" ( use the ecosystem to get this action) to go through each chars in turn to process them.

 you may want also to use ArrayMaker to store your results, especially if you don't know the number of digits ( meaning you can't hardcode three values for example).

Bye,

 Jean

Gav (HeyBud)

  • Full Member
  • ***
  • Posts: 126
    • Tumblr
Re: Help with breaking up a 3 digit int into 3 separate integers
« Reply #2 on: June 15, 2014, 09:40:40 AM »
Jean,
I just wanted to let you know this solution worked for me.
Thank you!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

 Thanks.

Bye,

 Jean