quote:Original post by CGameProgrammer
(8 is 111 for example).
um, actually 8 is 1000 , 111 bin = 7 in decimal
to quote from my favorite t-shirt "there are only 10 types of people in this world. Those that understand binary, and those that dont"
to answer your question, hex to int is very easy
hex goes 0 to F, with 0 = 0 decimal, and f = 15 decimal (16 unique characters)
basicly, instead of going ...8,9,10,11 you go ...8,9,A,B
so 0Ah (lowercase h denotes hex) = 10 decimal, FFh = 255 decimal
from there it''s simple math.
also, dont use the routine you''re talking about hoping to get random numbers. If the built in rand function isnt enough for you seed the following code with 2 rand()''s seeded from 2 seperate timeGetTime()''s and that should be more random than you ever would need
float noise(int x, int y){ int temp=0; int count=0; _asm { pushad mov eax, 57 mul y add eax, x mov count, eax shl eax, 13 mov temp, eax popad } temp=temp^count; _asm { pushad mov eax, temp mov ebx, eax mul eax mov edx, 15731d mul edx add eax, 789221d mul ebx add eax, 1376312589d and eax, 7fffffffh //do the division and subtraction here mov temp, eax popad } return (float)(1.0-(float)temp/1073741824.0);}
note: unfinished assembly, i got lazy and wrote the floating point part in c code, it''s really bad assembly at that too