Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Split an integer into binary equivalent integers
SUBMITTED BY:
Guest
DATE:
June 4, 2013, 7:09 p.m.
FORMAT:
C++
SIZE:
579 Bytes
Raw
Download
Tweet
HITS:
1255
Go to comments
Report
#include
<string>
#include
<sstream>
using
namespace
::
std
;
int
main
()
{
unsigned
long
long
start
=
0xABCDEF1234567890
;
stringstream
ss
;
ss
<<
hex
<<
start
;
string
end
=
ss
.
str
();
string
firsthalf
=
end
.
substr
(
0
,
8
);
string
endhalf
=
end
.
substr
(
8
,
8
);
ss
.
str
(
string
());
ss
<<
hex
<<
firsthalf
;
unsigned
long
firstint
;
ss
>>
firstint
;
stringstream
ss2
;
ss2
<<
hex
<<
endhalf
;
unsigned
long
secint
;
ss2
>>
secint
;
printf
(
"
\n
%s=>%lu
\n\n
%s=>%lu"
,
firsthalf
,
firstint
,
endhalf
,
secint
);
return
0
;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus