Is there a way to combine four numbers into one and still be able do check the individual values?

244 Views Asked by At

I do have four separate values in my script and in order for them to be processed further they need to be somehow combined into one and I have to be able to read the one combined number without alteration and know the values of the four. The first is either 1/0 and the three are numbers 0-99 with one decimal place. I am sorry if it is a dumb question, but I can't think of anything clever right now. Thank you very much

1

There are 1 best solutions below

1
On BEST ANSWER

Following lulu's suggestion, if your numbers are $a,b,c,d$ you could make your combined number $n=a10^6+b10^4+c10^2+d$. To extract $b$ you can take $(n \bmod 10^6) \operatorname { div } 10^4$ where the div is integer divide.