English 中文(简体)
带有基本算术的整数散列
原标题:Integer hashing with basic arithmetic
I am currently working in a language made for the Hypixel Housing gamemode in Minecraft called HSL, which only supports basic arithmetic, namely subtraction, multiplication and division. All numbers are also 64 bit integers, with no strings or fancy operations beside the ones mentioned above. I ve been looking for a while and have yet to find any proper basic hashing methods within these guidelines. I have attempted to get assistance on this through various means such as this gist but have trouble implementing it within the rules I outlined above.
问题回答
It s not entirely clear what your constraints are, but if you want a strong hash function using those basic operations, one easy (but somewhat slow) way is to slice the 64-bit number into say either 8-bit indices into tables of 256 random 64-bit numbers. For positive numbers, you can effectively shift right by dividing by a power of two, and shift left by multiplying by a power of two: using this with subtraction, you can find out the 0..255 value of any given 8-bit slice of the input, then use it as an array input. With a bit more thought or special casing, you can get it working for negative numbers. Get the eight numbers from the table and XOR them together.




相关问题
Maths in LaTex table of contents

I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: subsubsection{The expectation of (X^2)} Causes an error in the file that contains the ...

Math Overflow -- Handling Large Numbers

I am having a problem handling large numbers. I need to calculate the log of a very large number. The number is the product of a series of numbers. For example: log(2x3x66x435x444) though my actual ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Subsequent weighted algorithm for comparison

I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2 s value (1.5) is more ...

热门标签