From one string to several integers
#8

Quote:
Originally Posted by knackworst
Посмотреть сообщение
Thank you very much, this works
Btw what do you mean with store it into a 32-bit cel?
And how would I convert a string into different integers if there were more values than just 0 and 1, let's say 1, 2, 3?

(+Rep btw)
Well you only use 0 or 1 also binary values than you can store these number binary

Lets recreate this number 1100001000000000000000001
pawn Код:
new variable = 0;

variable |= 1 << 0; // it starts from the right with 0
variable |= 1 << 18;
variable |= 1 << 23;
variable |= 1 << 24;

printf("0b%b", variable); // prints 0b1100001000000000000000001
There are enough bit manipulations tutorials out there

If you just want to convert a number within string to an integer than subtract the value of the character '0' fromt it
It should be clear if you look at the ASCII table ('0' represents 48 or 0x30)
Reply


Messages In This Thread
From one string to several integers - by knackworst - 28.10.2014, 20:10
Re: From one string to several integers - by fordawinzz - 28.10.2014, 20:16
Re: From one string to several integers - by knackworst - 28.10.2014, 20:17
Re: From one string to several integers - by RedFusion - 28.10.2014, 20:22
Re: From one string to several integers - by fordawinzz - 28.10.2014, 20:30
AW: From one string to several integers - by Nero_3D - 28.10.2014, 20:31
Re: AW: From one string to several integers - by knackworst - 28.10.2014, 20:39
AW: Re: AW: From one string to several integers - by Nero_3D - 28.10.2014, 21:16

Forum Jump:


Users browsing this thread: 1 Guest(s)