Z
Z
Zakhar Shaikov2018-11-09 13:10:47
PHP
Zakhar Shaikov, 2018-11-09 13:10:47

PHP function to convert combination of 8 bits to a number in the range 0-256?

There is a combination of 8 bits, as you know, 256 characters can be encrypted in one byte! Is there a ready-made PHP function capable of converting a random combination of 8 bits into a number in the range (0-256)
An example of a function input is a byte
0-0-0-0-0-0-0-0 = 0
0-0-0-0- 0-0-0-1 = 56
0-0-0-0-1-0-1-0 = 108
And so on! Note the number assigned to the combination may be chosen randomly!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2018-11-09
@OnYourLips

ord function

A
Anatoly Medvedev, 2018-11-09
@balamyt92

Your tags are wrong, this is not higher mathematics or combinatorics, this is ordinary computer science of the 10th grade. You need to convert from binary to decimal (which we use). The php.net/manual/ru/function.bindec.php
function will help you with this if it is part of the solution of a practical problem, and if you need to directly implement the function for educational purposes, then we will not solve your homework for you :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question