Weird integers

Discussion and feedback on Construct 2

Post » Tue May 19, 2015 12:49 pm

I'm trying to implement a simple hashcode formula, which results in this weird numbers: 4.788467514771005e+96

http://www.coderanch.com/t/395027/java/java/Jason-Bloch-hashCode-formula

Is it possible to convert it to normal integer?
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue May 19, 2015 1:23 pm

Wouldn't round(x), floor(x), ceil(x) or int(x) do the trick?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue May 19, 2015 2:15 pm

Nope, tried that already. I want to use this hashcodes in a multiplayer game to check if grid state is in sync. The problem is when this number gets transmitted to another client it changes slightly, may be it is getting converted to a string.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393

Post » Tue May 19, 2015 2:30 pm

You can't do this in C2 as is. C2 uses floats internally, but a hash calculation must use integers. There is a hash plugin. See if that is sufficient. Otherwise you need this written in your own plugin.

viewtopic.php?t=62215&start=0
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue May 19, 2015 2:33 pm

You can either store it as a string, or attempt to convert it to an integer, but it looks like you'll lose some precision when you do that.
B
3
Posts: 5
Reputation: 185

Post » Wed May 20, 2015 8:44 am

Thanks guys, I will try this CB Hash plugin.
B
45
S
11
G
4
Posts: 517
Reputation: 7,393


Return to Construct 2 General

Who is online

Users browsing this forum: Colludium, Dankey, Lancifer, Rei TheMartianCat and 12 guests