View previous topic :: View next topic |
Author |
Message |
Allroundeath How do I cheat?
Reputation: 0
Joined: 26 Jan 2015 Posts: 6
|
Posted: Thu Nov 19, 2015 4:18 pm Post subject: 4byte to float |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Nov 19, 2015 4:26 pm Post subject: |
|
|
Code: | import struct
bytes = b"\x00\x00\x80\x3F"
print(struct.unpack("<f",bytes)[0]) |
|
|
Back to top |
|
 |
Allroundeath How do I cheat?
Reputation: 0
Joined: 26 Jan 2015 Posts: 6
|
Posted: Thu Nov 19, 2015 4:33 pm Post subject: |
|
|
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 |
|
 |
|