[fpc-pascal] C# translatation
Ryan Joseph
ryan at thealchemistguild.com
Sun Jan 8 10:55:17 CET 2017
I’m going to attempt to translate a perlin noise function (from https://gist.github.com/Flafla2/f0260a861be0ebdeef76) but there are a few things that stopped me from starting.
1) What is & doing in this assignment? I see this many places in assignments.
int h = hash & 15;
2) % is the mod operator in pascal right? So what is the modular assignment %=? num = num mod repeat?
p[x] = permutation[x%256];
if (repeat > 0) num %= repeat;
3) Adding the tertiary operator?
return ((h&1) == 0 ? u : -u)+((h&2) == 0 ? v : -v);
Here’s an easier example. Did I do that correctly?
if h < 8 then
u := x
else
u := y;
double u = h < 8 /* 0b1000 */ ? x : y;
Thanks for helping.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list