Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Double To Hexadecimal Convertion [Src included]

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:
[Image: xmeudIZ.png]

Now ofc ive modified my methods to my needs but the orginal creator of the method is: Greatvolk

Well, good luck ^^ -Barret
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.
(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:17 AM)Cornflower Blue இڿڰۣ-ڰۣ— Wrote:  There isn't no reply's because this is not a rat source or a RunPE.

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.
(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 08:46 AM)TheBarret Wrote:  I'll look into it cornz, first i need to get a grasp how basics work i cannot just drive off without knowing ^^

On top of that you said that you are not the most up to date with the newest GDI trends.
(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"
(Sep 7, 2014 09:19 AM)TheBarret Wrote:  ehm yeah i just wrote that? whats different of "not knowing" and "not up to date"

Was talking about your, not interested to learn attitude that you had about GDI today, but nvm. And because this new tech uses the GPU, I don't really see how that will improve performance on my shitty GPU, off topic ofc.
Thank you at: TheBarret, for this code.
Nice addition to our knowledge.... Thanks ;)
BTC - bc1q3efew3yzfwhdz290dafykaw0a2w56g2j69g2c6
ETH - 0xf1c873217032468990D3313da6509D1b813c4671
USDT - 0xf1c873217032468990D3313da6509D1b813c4671
PP - [email protected]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by WizardLizardOct 10, 2017 07:18 AM 5 286 Oct 10, 2017 07:18 AM
Last Post: UB3R5W4G0V3RL0RD
[Java] by ♥Quantum♥Apr 8, 2017 12:05 PM 4 208 Apr 8, 2017 12:05 PM
Last Post: thepixelhacker
[Python] by InfamiaJan 30, 2017 02:40 PM 3 136 Jan 30, 2017 02:40 PM
Last Post: Infamia