For some time ive been coding arround my own projects and i stumbled upon a problem
where my engine handles numbers as a decimal precision type (double) and since last night
i finally added the hexadecimal value support in the interpreter.
But wait, doubles and hex values, does that work? yes it can and you have a few options to do so.
One of them can be find on the MSDN itself but i rly wanted a quick convertion that goes both ways.
MSDN example:
BitConverter.DoubleToInt64Bits
http://msdn.microsoft.com/en-us/library/....110).aspx
Code Dim longValue As Long
longValue = BitConverter.DoubleToInt64Bits( DblValue )
The other option i found was to make a structure with FieldOffsetAttribute with two fields; Ulong and Double.
Structure:
Code <StructLayout(LayoutKind.Explicit)> _
Structure Double2ulong
<FieldOffset(0)> Public D As Double
<FieldOffset(0)> Public UL As ULong
End Structure
Then we setup our methods to do the proper assignment:
Double to hexadecimal
Code Public Function DoubleToHex(d as Double) As String
Return New Double2ulong() With {.D = d}.UL.ToString("X")
End Function
Hexidecimal to Double
Code Public Function HexToDouble(str as string) As Double
Return New Double2ulong() With {.UL = ULong.Parse(str, NumberStyles.AllowHexSpecifier)}.D
End Function
Result:
Now ofc ive modified my methods to my needs but the orginal creator of the method is: Greatvolk
Well, good luck ^^ -Barret
(Sep 7, 2014 07:52 AM)SIM-1456245 Wrote: Well done Barret, you did it again, you posted one if those things that makes a lot of frustration, but yet again, no replies. You people should be ashamed.
There isn't no reply's because this is not a rat source or a RunPE.
(Sep 7, 2014 08:20 AM)LordCoder Wrote: Or a crypter, DDoS'er, multi tool for l33t h4xx0r kids... That kind of people yeah. Barret this source is very useful, I also had to deal with hex numbers and they were pretty difficult to do what you want to do. Your posts deserve more popularity.
int to hex is easy to do, never tried float to hex.
There was a typo in the hex string to double method, its fixed now. ^^
(Sep 7, 2014 08:31 AM)TheBarret Wrote: There was a typo in the hex string to double method, its fixed now. ^^
You need to read my thread, would be a awesome update for your Tango engine.
https://hackforums.net/showthread.php?tid=4433686
(Sep 7, 2014 08:32 AM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote: You need to read my thread, would be a awesome update for your Tango engine.
https://hackforums.net/showthread.php?tid=4433686
Yeah ive read some parts of it indeed, it does catches my intrest Cornz.
We could merge somekind of sub-version of the new engine with your project i suppose.
(Sep 7, 2014 08:36 AM)TheBarret Wrote: Yeah ive read some parts of it indeed, it does catches my intrest Cornz.
We could merge somekind of sub-version of the new engine with your project i suppose.
I didn't make it, Microsoft did, it has the same method as GDI, but uses the GPU for rendering. If you want your Tango game engine thing pristine, you should add this Win2D.
(Sep 7, 2014 08:39 AM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote: I didn't make it, Microsoft did, it has the same method as GDI, but uses the GPU for rendering. If you want your Tango game engine thing pristine, you should add this Win2D.
I'll look into it cornz, first i need to get a grasp how basics work i cannot just drive off without knowing ^^
(Sep 7, 2014 09:09 AM)SIM-1456245 Wrote: On top of that you said that you are not the most up to date with the newest GDI trends.
ehm yeah i just wrote that? whats different of "not knowing" and "not up to date"
I doubt if any of you (or a very little amount of coders) arround here will ever use it tho ^^
or without structure
Dim D = 1.12345
MsgBox(D.ToString.SelectMany(Function(s) Hex(Asc(s))).ToArray)
(Sep 9, 2014 08:38 AM)TheUnknownProgrammer Wrote: That won't return the correct hexadecimal representation of the double, but the representation of the digit characters that make the double a readable number. Two completely different things.
OT: I am not sure why this is useful actually. When would it be beneficial to write down floating point numbers as a hexadecimal string?
😊
Dim D = 1.12345
MsgBox(BitConverter.GetBytes(D).Reverse.SelectMany(Function(b) Hex(b)).ToArray)
Or
MsgBox(BitConverter.GetBytes(D).Reverse.SelectMany(Function(b) b.ToString("X2")).ToArray)
(Sep 9, 2014 01:32 PM)Nikey646 Wrote: ...MsgBox...Really?
Only3, go to your largest project, remove the Microsoft.VisualBasic Namespace, and clear out all unused references. How many errors? Your code is irrelevant googled crap until you get that down to 0...Seem fair?
😁 Console.Write(BitConverter.GetBytes(D).Reverse.SelectMany(Function(b) b.ToString("X2")).ToArray)
(Sep 9, 2014 11:26 AM)nathan72389 Wrote: im kinda here with ya also. although it is a good snipp of code (cant deny that). I do not see where the average coder would find this useful. The only thing that i would be able to think of would be to use it in some sort of plugin for a cheat engine type of project. Dont get me wrong, after reading the code. It absolutely looks clean enough that it should work. Personally i dont do much with anything of the nature so i dont have the exact environment to test it on. other than telling you "good job" on what you have described, and knowing your previous work, i can only say good job. Have you thought about taking this and putting it on another forum where it may be more appreciated? you may get better (not the same quantity, but better quality) advice / responses there.
edited for typos and English stupid
I agree with that Nathan,
the usage in general is not often used like this,
For my personal project, the script engine, all the numbers are handled as double, so i had to make a convertion
method going both ways, ofc it also understands normal hex values.
example of "Hello, World" :
So thats was my main reason to implement a floating point hexadecimal convertor.
- B
|