How does modulus division work in this case?
cthomas
Posts: 17
I came across this on the forum looking for how to extract a digit from a multi-digit number and when I first read it, I had no idea how it would work.
"Welcome to the insanely fun world of Propeller!!
If you need to extract the numbers to format it as a string you can use the readily available objects (numbers and simple_numbers).
Moreover if you check the objects you'll find a lot of code to handel that.
Anyway the solution is to combine / and // (the two division operators).
If you take 5678, and want to extract the 3rd digit, you can do something like that:
(5678/10)//10
5678/10 gives 567 (you must set the right power of 10 to extract the right digit)
567//10 gives 6 (this part applies in every case)"
To get the 6, shouldn't this be.... (5678/100)//10 ?
Thanks.
"Welcome to the insanely fun world of Propeller!!
If you need to extract the numbers to format it as a string you can use the readily available objects (numbers and simple_numbers).
Moreover if you check the objects you'll find a lot of code to handel that.
Anyway the solution is to combine / and // (the two division operators).
If you take 5678, and want to extract the 3rd digit, you can do something like that:
(5678/10)//10
5678/10 gives 567 (you must set the right power of 10 to extract the right digit)
567//10 gives 6 (this part applies in every case)"
To get the 6, shouldn't this be.... (5678/100)//10 ?
Thanks.
Comments
I appreciate it.
Craig