-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a serializable version of long. It is split into two ints inste…
…ad..
- Loading branch information
Kalle Sjöström
committed
Dec 19, 2014
1 parent
9decdc7
commit 6d9a76b
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.