I am writing a code where I need to convert some forms of no to binary no for some processing. I want the size of binary no based on the value stored in a variable for which I need to append some leading zeroes.
for example, say there is variable $size =15
Now I want to convert a no from decimal to 15 bit binary

I know how to manually give the count
for ex -
if we want 8 digit binary no from some decimal no then we will use-

```
    $data_binary = sprintf( "%08b", $initial_data );

```

But how to specify the size of binary no if the size is stored in some variable??

For example=

```
    If size =10
    decimal no =12
    required binary no = 0000001100

```