Thorham Posted August 21, 2017 Posted August 21, 2017 I have this hash function: hash = ((2860486313 * (3367900313 * x XOR 4093082899 * y)) RIGHTSHIFT 32) & 255 Anyone know if this will produce repeating sequences when the inputs are whole positive numbers starting at 0 and going up to 2^32? An example would be x and y starting at 0. X is incremented by 1 until x becomes 2^32, at this point x is reset to 0 and y is increased by 1. This is repeated until y is 2^32.
Handy andy Posted August 23, 2017 Posted August 23, 2017 On 21/08/2017 at 7:17 AM, Thorham said: I have this hash function: hash = ((2860486313 * (3367900313 * x XOR 4093082899 * y)) RIGHTSHIFT 32) & 255 Anyone know if this will produce repeating sequences when the inputs are whole positive numbers starting at 0 and going up to 2^32? An example would be x and y starting at 0. X is incremented by 1 until x becomes 2^32, at this point x is reset to 0 and y is increased by 1. This is repeated until y is 2^32. Your question doesnt make much sense. You are using a mixture of boolean and mathematical operators, with different representations of boolean operators. the AND 255 at the end will cancel the bits above 255 in the rest of the function. Also if you are doing a 32 bit right shift without wrapping around, you are clearing the registers and you will wind up with an output of zero. if you are wrapping the bits around from bit 0 to bit 31, what is the point of the shift. Is there a reason for your question. Have you been smoking hash. question mark
Thorham Posted August 24, 2017 Author Posted August 24, 2017 (edited) My question makes perfect sense. 1. The XOR and & thing are a simple mistake. Should Be XOR and AND. 2. The booleans are bitwise operators (what else could they be?). 3. The hash variable is clearly not 32 bits wide (why would I expect to get anything other than zero if I shift out all the bits?). Basically I tried to write the following WORKING line of code in a more general format: Int64 hash = ((2860486313 * (3367900313 * x ^ 4093082899 * y)) >> 32) & 255; Yes, there is a reason for my question. I don't have a maths background and don't know how to work out the period (if you will) of this hash function. And no, I haven't been using any cannabis products. Don't see how this is relevant anyway. Next time, don't reply if you don't understand the question. In this case it's very obvious that you have no clue. Anyway, the hash function is flawed and I've replaced it with this one that seems to do the job: Int64 hash = ((6082394749206781697 * (1732050807568877293 * i ^ 8650415921358664919 * j ^ 3842148274728412483)) >> 48) & 255; Edited August 24, 2017 by Thorham
Sensei Posted August 31, 2017 Posted August 31, 2017 (edited) On 23.08.2017 at 6:05 PM, Handy andy said: Your question doesnt make much sense. You are using a mixture of boolean and mathematical operators, with different representations of boolean operators. the AND 255 at the end will cancel the bits above 255 in the rest of the function. Also if you are doing a 32 bit right shift without wrapping around, you are clearing the registers and you will wind up with an output of zero. if you are wrapping the bits around from bit 0 to bit 31, what is the point of the shift. Is there a reason for your question. Have you been smoking hash. question mark Do you have idea what is hash function/hash value in computer science? https://en.wikipedia.org/wiki/Hash_function Thorham has list/array with 256 entries which are pointers to further lists. That's why he is doing AND 0xFF at the end to limit index to only allowed number of entries.. He will calculate hash (index to the top most list/array) from element, and then put element in the appropriate list (at appropriate index)... Edited August 31, 2017 by Sensei
Handy andy Posted September 1, 2017 Posted September 1, 2017 (edited) 10 hours ago, Sensei said: Do you have idea what is hash function/hash value in computer science? https://en.wikipedia.org/wiki/Hash_function Thorham has list/array with 256 entries which are pointers to further lists. That's why he is doing AND 0xFF at the end to limit index to only allowed number of entries.. He will calculate hash (index to the top most list/array) from element, and then put element in the appropriate list (at appropriate index)... No I was not, it was not made clear in the question ! Hash was something else when I was in university, and DNA sequencing was not happening. At first glance Hash looks like indexing mixed up with encryption something I never got involved with. I will read the link a second time more slowly. But clearly Thorham has worked out without assistance, if he had written down the code and mentioned the Hash_function maybe I would have tried to help, the original question looked like nonsense. Edited September 1, 2017 by Handy andy added a bit
Thorham Posted September 1, 2017 Author Posted September 1, 2017 5 hours ago, Handy andy said: the original question looked like nonsense. Understandable, seeing how you didn't understand it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now