|
From: Ioannis V. <no...@ho...> - 2003-03-05 12:45:12
|
-------Original Message-------=0D
=0D
From: Per Westermark=0D
Date: =D4=E5=F4=DC=F1=F4=E7, 5 =CC=DC=F1=F4=E9=EF=F2 2003 2:39:12 =EC=EC=0D
To: Ioannis Vranos=0D
Cc: Dev-C++ Mailing List=0D
Subject: Re: [Dev-C++] Character variables=0D
=0D
If I need a set of 100 bits, the bitset implementation is nice, but for=0D
multicharacter manipulation it doesn't give an improved portability, whil=
e=0D
it is more code than=0D
=0D
(unsigned('a') << 8) | unsigned('b')=0D
=0D
=0D
=3D=3D> Why isn't my code portable?=0D
=0D
=0D
bitset<numeric_limits<char>::digits10 *2>tag('a');=0D
=0D
tag<<=3Dnumeric_limits<char>::digits10;=0D
=0D
tag&=3Dbitset<numeric_limits<char>::digits10 *2>('b');=0D
=0D
=0D
=3D=3D> It is completely portable.=0D
=0D
=0D
=3D=3D> Yes it is more code than your code above because my code was made=
to be
portable. The equivalent would be:=0D
=0D
=0D
(bitset<sizeof(unsigned)>('a')<<8) | bitset<sizeof(unsigned)>('b')=0D
=0D
=0D
=0D
=0D
The problem is still that depending on machine and compiler I might have=0D
to do=0D
(unsigned('b') << 8) | unsigned('a')=0D
or=0D
(unsigned('a') << 24) | unsigned('b')=0D
or=0D
(unsigned('b') << 24) | unsigned('a')=0D
or=0D
=2E..=0D
instead, because there isn't a defined standard how the individual=0D
characters should be stored in the integer.=0D
=0D
=0D
=3D=3D> ?=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys=20 |