I'm only using this for personal use, just to calculate things..
but I need some help.. I use VisualStudio 2005
first, i used VB
then for some reason i have to convert it to C#, here is the code:Code:Private Function PRNG(ByVal seed As String) As String Dim temp As String = "" Dim t As UInt64 t = Convert.ToUInt64("0x41C64E6D", 16) * Convert.ToUInt64(seed, 16) + Convert.ToUInt64("0x6073", 16) temp = Hex(t) If temp.Length < 16 Then For t = 0 To 15 - temp.Length Step 1 'just to add zero temp = "0" & temp Next End If PRNG = temp End Function
but i get different result, well the LSB is the same, but the MSB is different.. any clue?Code:using Microsoft.VisualBasic; //for Conversion private const UInt64 factor = 0x41C64E6D; private const UInt64 adder = 0x6073; //... private string generate(String seed) { return temp = Conversion.Hex( (factor * Convert.ToUInt64(seed, 16) + adder)); }
thx a lot
I am not sure why the result would be different, but here's what the VB.Net code converted to C# looks like for me (courtesy of this page.):
Code:private string PRNG(string seed) { string temp = ""; UInt64 t = default(UInt64); t = Convert.ToUInt64("0x41C64E6D", 16) * Convert.ToUInt64(seed, 16) + Convert.ToUInt64("0x6073", 16); temp = Conversion.Hex(t); if (temp.Length < 16) { for (t = 0; t <= 15 - temp.Length; t += 1) { //just to add zero temp = "0" + temp; } } return temp; }
My Pokémon stuff on Google Drive!
Spoiler
To use (some of) my software you need the .Net Framework!
codemonkey85 on
Pokémon Black 2: 1507-3503-1914
public UInt32 GetNext32BitNumber()
{
seed = seed * 0x41C64E6D + 0x6073;
return seed;
}
No need for all that 64 bit stuff.
Nope. The return will be uint anyhow.
Thanks for all of the help, I'll try that again..
oh, for the UInt64, i've tried UInt32, sometimes it says overflow.. so I decided to use UInt64.. but I think Mingot is correct, I'll try again..
@Damio
the modulo thing is somehow does not effect the result..
well I think it's because the conversion, somehow the result from C# is like rounded up..
thanks all..
Bookmarks