Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Converting hex to decimal?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Wed Jul 30, 2008 10:52 pm    Post subject: [C++] Converting hex to decimal? Reply with quote

it's kinda hard to explain this but its like this:

my program reads a value for a pointer
i use a label to show the value
when the value is a negative it's like 4,XXX,XXX,XXX(its the number where you hex the negative value and make it back into a decimal value)

What i want to do is make it so then it wouldnt show the 4 billion value but show the negative value instead. Crying or Very sad help please
Back to top
View user's profile Send private message
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Thu Jul 31, 2008 1:11 am    Post subject: Reply with quote

In your case, check on wsprintf()
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Thu Jul 31, 2008 8:40 am    Post subject: Reply with quote

Code:
blabla.ToInt();
?
_________________
Gone
Back to top
View user's profile Send private message
Cx
Master Cheater
Reputation: 0

Joined: 27 Jul 2007
Posts: 367

PostPosted: Thu Jul 31, 2008 6:13 pm    Post subject: Reply with quote

GMZorita wrote:
Code:
blabla.ToInt();
?

WHAT IS THIS NONSENSE?
JAVA?

_________________

armed with this small butterfly net
i will face the world alone
& never be lonely.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Thu Jul 31, 2008 6:47 pm    Post subject: Reply with quote

Cx wrote:
GMZorita wrote:
Code:
blabla.ToInt();
?

WHAT IS THIS NONSENSE?
JAVA?


Uh... I think it's Borland C++.

_________________
Back to top
View user's profile Send private message
Cx
Master Cheater
Reputation: 0

Joined: 27 Jul 2007
Posts: 367

PostPosted: Thu Jul 31, 2008 8:43 pm    Post subject: Reply with quote

lurc wrote:
Cx wrote:
GMZorita wrote:
Code:
blabla.ToInt();
?

WHAT IS THIS NONSENSE?
JAVA?


Uh... I think it's Borland C++.

Haha. I'm just giving him a hard time.

_________________

armed with this small butterfly net
i will face the world alone
& never be lonely.
Back to top
View user's profile Send private message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Thu Jul 31, 2008 9:12 pm    Post subject: Reply with quote

ty for the help guys but i found out why it showed that number Very Happy
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Aug 01, 2008 12:13 am    Post subject: Reply with quote

aznkidtroll wrote:
ty for the help guys but i found out why it showed that number Very Happy


guessing it was a case of signed / unsigned?
Back to top
View user's profile Send private message
Nuclear898
Grandmaster Cheater Supreme
Reputation: 0

Joined: 04 Jun 2006
Posts: 1597
Location: The Netherlands

PostPosted: Fri Aug 01, 2008 1:54 am    Post subject: Reply with quote

Code:
#include <iostream>

int main( void )
{
   char text[128];
   int number;
   printf("Which number do you want to convert to hex? ");
   std::cin >> number;
   sprintf(text,"%x",number);
   printf("%d is %s in hex.\n",number,text);
   std::cin.get();
   std::cin.get();
}


That's what I found some time ago, but you guys will probably say it's a bad way to do it or something...
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Aug 01, 2008 9:04 am    Post subject: Reply with quote

Nuclear898 wrote:
That's what I found some time ago, but you guys will probably say it's a bad way to do it or something...
:P More of a C++ way:
Code:
#include <iostream>

int main(int argc, char *argv[])
{
   int i;
   std::cout << "Num: ";
   std::cin >> i;
   std::cout << "Hex: " << std::hex << i;

   return EXIT_SUCCESS;
}
std::hex works with stringstream and so on..
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Fri Aug 01, 2008 12:01 pm    Post subject: Reply with quote

use "(int)hex" ?
lol idk if it will works but i think it does.

_________________
Gone
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Fri Aug 01, 2008 3:52 pm    Post subject: Reply with quote

Jani wrote:
Nuclear898 wrote:
That's what I found some time ago, but you guys will probably say it's a bad way to do it or something...
Razz More of a C++ way:
Code:
#include <iostream>

int main(int argc, char *argv[])
{
   int i;
   std::cout << "Num: ";
   std::cin >> i;
   std::cout << "Hex: " << std::hex << i;

   return EXIT_SUCCESS;
}
std::hex works with stringstream and so on..


Yep. This will work
Back to top
View user's profile Send private message Send e-mail
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Fri Aug 01, 2008 4:05 pm    Post subject: Reply with quote

kitterz wrote:
Jani wrote:
Nuclear898 wrote:
That's what I found some time ago, but you guys will probably say it's a bad way to do it or something...
:P More of a C++ way:
Code:
#include <iostream>

int main(int argc, char *argv[])
{
   int i;
   std::cout << "Num: ";
   std::cin >> i;
   std::cout << "Hex: " << std::hex << i;

   return EXIT_SUCCESS;
}
std::hex works with stringstream and so on..


Yep. This will work

He wants Hex->Int not Int->Hex.

_________________
Gone
Back to top
View user's profile Send private message
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Sat Aug 02, 2008 12:44 am    Post subject: Reply with quote

GMZorita wrote:
kitterz wrote:
Jani wrote:
Nuclear898 wrote:
That's what I found some time ago, but you guys will probably say it's a bad way to do it or something...
Razz More of a C++ way:
Code:
#include <iostream>

int main(int argc, char *argv[])
{
   int i;
   std::cout << "Num: ";
   std::cin >> i;
   std::cout << "Hex: " << std::hex << i;

   return EXIT_SUCCESS;
}
std::hex works with stringstream and so on..


Yep. This will work

He wants Hex->Int not Int->Hex.


Windows Calc.
Back to top
View user's profile Send private message Send e-mail
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sat Aug 02, 2008 5:27 am    Post subject: Reply with quote

GMZorita wrote:
He wants Hex->Int not Int->Hex.
I was replying to Nuclear898 (that's why the quote.). Also the same stuff works the other way round too, if you're enough smart to understand that. Btw.. Int is a integer, hex is a representation of the integer.
Code:
#include <iostream>

int main(int argc, char *argv[])
{
   int i;
   std::cout << "Num: ";
   std::cin >> std::hex >> i;
   std::cout << "Dec: " << std::dec << i;

   return EXIT_SUCCESS;
}
Code:
./a.out
Num: A
Dec: 10
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites