Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Calculator.php

function Calculator::toBinary

Converts a decimal number to a binary string.

Parameters

string $number The number to convert, positive or zero, only digits.:

1 call to Calculator::toBinary()
Calculator::bitwise in vendor/brick/math/src/Internal/Calculator.php
Performs a bitwise operation on a decimal number.

File

vendor/brick/math/src/Internal/Calculator.php, line 629

Class

Calculator
Performs basic operations on arbitrary size integers.

Namespace

Brick\Math\Internal

Code

private function toBinary(string $number) : string {
    $result = '';
    while ($number !== '0') {
        [
            $number,
            $remainder,
        ] = $this->divQR($number, '256');
        $result .= \chr((int) $remainder);
    }
    return \strrev($result);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal