I'm trying to make a fast little function that'll give me a
random looking (but deterministic) value from an x,y position on
a grid. I'm just going to run each co-ord that I need through an
FNV-1a hash function as an array of bytes since that seems like a
fast and easy way to go. I'm going to n
On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote:
On Sat, 16 Jan 2016 14:34:54 +, Samson Smith wrote:
[...]
You can do this:
ubyte[] b = (cast(ubyte*) &a)[0 .. int.sizeof];
It is casting the pointer to `a` to a ubyte (or byte) pointer
and then taking a slice the size of int.
On Saturday, 16 January 2016 at 15:42:39 UTC, bearophile wrote:
Yazan D:
On Saturday, 16 January 2016 at 14:42:27 UTC, Yazan D wrote:
ubyte[] b = (cast(ubyte*) &a)[0 .. int.sizeof];
Better to use the actual size:
ubyte[] b = (cast(ubyte*) &a)[0 .. a.sizeof];
Bye,
bearophile
Good thinking,
On Saturday, 16 January 2016 at 16:28:21 UTC, Jonathan M Davis
wrote:
On Saturday, January 16, 2016 14:34:54 Samson Smith via
Digitalmars-d-learn wrote:
I'm trying to make a fast little function that'll give me a
random looking (but deterministic) value from an x,y position
on a grid