Skip to content

Commit

Permalink
Added a serializable version of long. It is split into two ints inste…
Browse files Browse the repository at this point in the history
…ad..
  • Loading branch information
Kalle Sjöström committed Dec 19, 2014
1 parent 9decdc7 commit 6d9a76b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Script/Utils/Id64.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UnityEngine;
using System.Collections;

[System.Serializable]
public class Id64
{
public int low;
public int high;

public Id64(long l) {
low = (int)(l & 0xFFFFFFFF);
high = (int)(l >> 32);
}

public static implicit operator long(Id64 l) {
long h = ((long)l.high) << 32;
long lo = l.low & 0x00000000FFFFFFFF;
return h | lo;
}

public static implicit operator Id64(long l) {
return new Id64(l);
}

public override bool Equals(System.Object b) {
long la = this;
long lb = ((Id64)b);
return la.Equals(lb);
}

public override int GetHashCode() {
long l = (long)this;
return l.GetHashCode();
}
}
8 changes: 8 additions & 0 deletions Script/Utils/Id64.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d9a76b

Please sign in to comment.