You are here

public static function ParagonIE_Sodium_Core_Util::numericTo64BitInteger in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core/Util.php \ParagonIE_Sodium_Core_Util::numericTo64BitInteger()

Convert any arbitrary numbers into two 32-bit integers that represent a 64-bit integer.

@internal You should not use this directly from another application

Parameters

int|float $num:

Return value

array<int, int>

3 calls to ParagonIE_Sodium_Core_Util::numericTo64BitInteger()
ParagonIE_Sodium_Core32_BLAKE2b::to64 in vendor/paragonie/sodium_compat/src/Core32/BLAKE2b.php
Convert an arbitrary number into an SplFixedArray of two 32-bit integers that represents a 64-bit integer.
ParagonIE_Sodium_Core_BLAKE2b::to64 in vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php
Convert an arbitrary number into an SplFixedArray of two 32-bit integers that represents a 64-bit integer.
ParagonIE_Sodium_Core_Util::store64_le in vendor/paragonie/sodium_compat/src/Core/Util.php
Stores a 64-bit integer as an string, treating it as little-endian.

File

vendor/paragonie/sodium_compat/src/Core/Util.php, line 595

Class

ParagonIE_Sodium_Core_Util
Class ParagonIE_Sodium_Core_Util

Code

public static function numericTo64BitInteger($num) {
  $high = 0;

  /** @var int $low */
  $low = $num & 0xffffffff;
  if (+abs($num) >= 1) {
    if ($num > 0) {

      /** @var int $high */
      $high = min(+floor($num / 4294967296), 4294967295);
    }
    else {

      /** @var int $high */
      $high = ~~+ceil(($num - +~~$num) / 4294967296);
    }
  }
  return array(
    (int) $high,
    (int) $low,
  );
}