-
April 22nd, 2000, 03:04 PM
#1
How do I convert int to binary or hex data?
How do I convert int to binary or hex data?
I need convert int, short, int64 to hex data or binary data.
thank.
-
April 22nd, 2000, 03:45 PM
#2
Re: How do I convert int to binary or hex data?
What do you mean by "Binary/Hex Data?" in windows, all data (Char's, Strings, Integers, etc...) is stored as bytes. The bytes are a sequence of 8-binary bits.
Now, i assume you want to convert an integer to a string that represents the binary/hex data
so 255 will be hex 000000FF and Binary 00000000000000000000000011111111.
How do you do this?
There is 2 magic functions:
1. _itoa - converts an integer to Hex / binary
Use the following code:
int to hex
int integer = 255;
char Hex[9];
_itoa(integer, Hex, 16)
int to Bin
char binary[33];
int integer = 255;
_itoa(integer, binary, 2);
2. _i64toa - same as itoa, but for int64s
---===---
I'm not here for the rates, but rating a post is a good way for me to know how much i helped.
---===---
Daniel
-
August 27th, 2013, 08:04 AM
#3
Re: How do I convert int to binary or hex data?
Originally Posted by DanielK
What do you mean by "Binary/Hex Data?" in windows, all data (Char's, Strings, Integers, etc...) is stored as bytes. The bytes are a sequence of 8-binary bits.
Now, i assume you want to convert an integer to a string that represents the binary/hex data
so 255 will be hex 000000FF and Binary 00000000000000000000000011111111.
How do you do this?
There is 2 magic functions:
1. _itoa - converts an integer to Hex / binary
Use the following code:
int to hex
int integer = 255;
char Hex[9];
_itoa(integer, Hex, 16)
int to Bin
char binary[33];
int integer = 255;
_itoa(integer, binary, 2);
2. _i64toa - same as itoa, but for int64s
---===---
I'm not here for the rates, but rating a post is a good way for me to know how much i helped.
---===---
Daniel
thank you Daniel and i agree with you. you solution solved my problem. thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|