mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
All these files need further edits + other optimization files + moving of files
19 lines
311 B
PHP
19 lines
311 B
PHP
<?php
|
|
|
|
class Gray {
|
|
public static function encode(int $source) : int
|
|
{
|
|
return $source ^ ($source >> 1);
|
|
}
|
|
|
|
public static function decode(int $gray) : int
|
|
{
|
|
$source = $gray;
|
|
|
|
while($gray >>= 1) {
|
|
$source ^= $gray;
|
|
}
|
|
|
|
return $source;
|
|
}
|
|
} |