Link to home
Create AccountLog in
Avatar of Spad3z
Spad3z

asked on

Change Format to hex

Hello experts,

My question that I've been stuck on for a while is how can i add "0x" in front of a number without changing the actual number itself.

In VC++ using namespace System It can be done like so..
int Number = 123456;
txtNumber->Text = Number.ToString("X8")

Open in new window

txtNumber->Text will show "0x123456".

But i want to do that exact thing without using the namspace System, and System::String.

and one more thing instead of having the number displayed into "txtNumber->Text" I'd rather have it be put back into "int Number". So each time i use "Number" it'll equal "0x123456".

Thanks for your help.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

The number 123456 is Not the same as 0x123456.  Try it in your calculator.  0x123456 = 1193046 decimal.
Avatar of Spad3z
Spad3z

ASKER

@DaveBaldwin - Yes I'm aware of that, I merely just want to add "0x" infront of any number. or if this makes things easier. Make 1193046 into 0x123456 within "int Number".
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Spad3z

ASKER

No solution found, as DaveBaldwin said does not work like that. I've found a way around my issue. Thank you for your time.
You're welcome, thanks for the points.