Post ATrAWemMACtvWzOPS4 by romainguy@androiddev.social
(DIR) More posts by romainguy@androiddev.social
(DIR) Post #ATr3j9rPjIAvizlwfI by friendlymike@androiddev.social
2023-03-21T22:55:09Z
0 likes, 0 repeats
this is my life nowfun hash(i: Long) = (i * 2654435761 % 2.toDouble().pow(32)).toInt()
(DIR) Post #ATr5HgBs8M7znJMmLA by benlikestocode@androiddev.social
2023-03-21T23:12:34Z
0 likes, 0 repeats
@friendlymike
(DIR) Post #ATrAWemMACtvWzOPS4 by romainguy@androiddev.social
2023-03-22T00:11:13Z
0 likes, 0 repeats
@friendlymike Looks like code to do dithering on the GPU :p
(DIR) Post #ATrAfCCBnyt5UIY0f2 by friendlymike@androiddev.social
2023-03-22T00:12:46Z
0 likes, 0 repeats
@romainguy I needed something to get from mastodon account IDs which are longs to crypto public key IDs which need to be integers for some odd reason. That was the coolest looking hashing function I found
(DIR) Post #ATsJgZoOZzcRld6xrU by cketti@social.int21.dev
2023-03-22T13:28:38Z
0 likes, 0 repeats
@friendlymike @romainguy Your function performs the modulo operation on double values. You'll likely want this instead:fun hash(i: Long) = (i * 2654435761 % 2.toDouble().pow(32).toLong()).toInt()This can be simplified to:fun hash(i: Long) = (i * 2654435761).toInt()
(DIR) Post #ATsPglnuamaUgYMPrM by friendlymike@androiddev.social
2023-03-22T14:35:57Z
0 likes, 0 repeats
@cketti @romainguy thank you ♥️