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 


4byte to float

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
Allroundeath
How do I cheat?
Reputation: 0

Joined: 26 Jan 2015
Posts: 6

PostPosted: Thu Nov 19, 2015 4:18 pm    Post subject: 4byte to float Reply with quote

Currently developing a program in Python that is essentially a trainer. It simply changes a value. I've included an interface with a slider and text box to set a value.

However, when I convert the value from endian to decimal, the number is 1112014848, which I believe to be DWORD? While I could use cheat engine and set pre-made values, I'd prefer to do the conversion in the program.

It's worth noting that everything is working properly, and I CAN change the value, but clearly the problem is that I'd like some flexibility with the value instead of needing to have pre-defined settings to choose from.

The question I'm asking is if anyone is familiar enough with Python to provide the solution to converting the value into float and vice-versa so that the values entered via text box/slider function properly.

The question seems really rather simple, but the reality is that I've been searching through API documentation for the last several hours and testing essentially everything I find to no avail.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Nov 19, 2015 4:26 pm    Post subject: Reply with quote

Code:
import struct
bytes = b"\x00\x00\x80\x3F"
print(struct.unpack("<f",bytes)[0])
Back to top
View user's profile Send private message
Allroundeath
How do I cheat?
Reputation: 0

Joined: 26 Jan 2015
Posts: 6

PostPosted: Thu Nov 19, 2015 4:33 pm    Post subject: Reply with quote

I want to hug you. I really do.

It dawned on me that I was doing it wrong. I was converting the bytes into long, and then trying to convert long into float.

Thanks a bunch.

Quick edit, before I start stressing over this later, to convert back to bytes I'd do... What exactly?
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 Discussions All times are GMT - 6 Hours
Page 1 of 1

 
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